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
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 " ()"`
200 LyxBase="${LyxName}-${LyXVersion}"
201 LyxApp="${LyxBase}.app"
202 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
203 LyxBuildDir="${LyxAppDir}.build"
204 LyxAppPrefix="${LyxAppDir}.app"
205 # if zip file is needed... remove the comment sign
206 #LyxAppZip="${LyxAppPrefix}.zip"
208 BuildSystem=`"${LyxSourceDir}/config/config.guess"`
210 # ---------------------------------
211 # DON'T MODIFY ANYTHING BELOW HERE!
212 # ---------------------------------
214 # don't change order here...
215 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
219 BACKGROUND="${LyxAppDir}.app/Contents/Resources/images/banner.png"
221 # Check for existing SDKs
222 SDKs=`echo /Developer/SDKs/MacOSX10*sdk`
227 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
228 case "${MACOSX_DEPLOYMENT_TARGET}" in
230 SDKROOT="/Developer/SDKs/MacOSX10.6.sdk"; export SDKROOT
233 SDKROOT=${SDKROOT:-"/Developer/SDKs/MacOSX10.5.sdk"}; export SDKROOT
238 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
239 SDKROOT=${SDKROOT:-"/Developer/SDKs/MacOSX10.5.sdk"}; export SDKROOT
242 echo Unknown or missing SDK for Mac OS X.
246 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
248 # These variables define the identifiers of the
249 # system (both Intel and PowerPC) to compile for.
250 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
251 # Only change these if necessary
253 HostSystem_i386="i686-apple-darwin8"
254 HostSystem_ppc="powerpc-apple-darwin8"
256 updateDictionaries() {
257 TMP_DIR="/tmp/lyx-build-$$"
258 mkdir -p "$1"/dict "$1"/thes
259 mkdir -p "$TMP_DIR" && (
260 for pack in "$1"/*.zip ; do
263 cd "$TMP_DIR" && unzip "${pack}" de_DE_comb.zip thes_de_DE_v2.zip
264 cd "$1"/dict && unzip -o "$TMP_DIR"/de_DE_comb.zip
265 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_de_DE_v2.zip
268 cd "$TMP_DIR" && unzip "${pack}" pl_PL.zip thes_pl_PL_v2.zip
269 cd "$1"/dict && unzip -o "$TMP_DIR"/pl_PL.zip
270 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_pl_PL_v2.zip
273 cd "$TMP_DIR" && unzip "${pack}" fr_FR.zip thes_fr_FR_v2.zip
274 cd "$1"/dict && unzip -o "$TMP_DIR"/fr_FR.zip
275 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_fr_FR_v2.zip
278 cd "$TMP_DIR" && unzip "${pack}" es_ES.zip es_MX.zip thes_es_ES_v2.zip
279 cd "$1"/dict && unzip -o "$TMP_DIR"/es_ES.zip
280 cd "$1"/dict && unzip -o "$TMP_DIR"/es_MX.zip
281 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_es_ES_v2.zip
284 cd "$TMP_DIR" && unzip "${pack}" pt_PT.zip
285 cd "$1"/dict && unzip -o "$TMP_DIR"/pt_PT.zip
286 cd "$1"/dict && unzip -o "$1"/pt_BR.zip
287 cd "$1"/thes && unzip -o "$1"/thes_pt_PT_v2.zip
290 cd "$TMP_DIR" && unzip "${pack}" it_IT.zip
291 cd "$1"/dict && unzip -o "$TMP_DIR"/it_IT.zip
292 cd "$1"/thes && unzip -o "$1"/thes_it_IT_v2.zip
295 cd "$TMP_DIR" && unzip "${pack}" ru_RU.zip
296 cd "$1"/dict && unzip -o "$TMP_DIR"/ru_RU.zip
297 cd "$1"/thes && tar xvf "$1"/thes_ru_RU_v2.tar.bz2
300 cd "$TMP_DIR" && unzip "${pack}" en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip
301 for zipfile in en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip ; do
302 ( cd "$1"/dict && unzip -o "$TMP_DIR/$zipfile" )
304 cd "$1"/thes && unzip -o "$1"/thes_en_US_v2.zip
307 cd "$TMP_DIR" && unzip -l "${pack}" | while read len date time zipfile ; do
311 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
312 cd "$1"/thes && unzip -o "$TMP_DIR"/"$zipfile"
314 [a-z][a-z]_[A-Z][A-Z].zip)
316 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
317 cd "$1"/dict && unzip -o "$TMP_DIR"/"$zipfile"
321 # echo Ignore dictionary package `basename "${pack}"`
329 if [ -d "${Qt4SourceDir}" -a ! -d "${Qt4BuildDir}" ]; then
330 echo Build Qt4 library ${Qt4SourceDir}
333 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
334 for arch in ${ARCH_LIST} ; do
335 ARCHS="${ARCHS} -arch ${arch}"
337 echo configure options:
338 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
340 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
343 cd "${QtInstallDir}" && (
346 for libnm in ${QtLibraries} ; do
347 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
352 # updateDictionaries "${DictionarySourceDir}"
355 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
356 # we have a private HunSpell source tree at hand...
357 # so let's build and install it
358 if [ -z "${HunSpellVersion}" ]; then
359 HunSpellVersion=`grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
362 HunSpellName="Hunspell"
363 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
365 echo Build hunspell library ${HunSpellBase}
366 echo configure options:
367 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
369 cd "${HunSpellSourceDir}"
371 # ----------------------------------------
372 # Build HunSpell for different architectures
373 # ----------------------------------------
374 FILE_LIST="libhunspell-1.2.0.dylib"
376 for arch in ${ARCH_LIST} ; do
378 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
379 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
380 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
381 "${HunSpellSourceDir}/configure"\
382 --prefix="${HunSpellInstallDir}"\
383 ${HunspellConfigureOptions}
384 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
385 make && make install${strip}
386 for file in ${FILE_LIST} ; do
387 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
388 mv "${HunSpellInstallDir}"/lib/${file}\
389 "${HunSpellInstallDir}"/lib/${file}-${arch}
391 echo Cannot build and install HunSpell for ${arch}.
396 # -------------------------
397 # Create universal binaries
398 # -------------------------
399 for file in ${FILE_LIST} ; do
401 for arch in ${ARCH_LIST} ; do
402 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
405 cd "${HunSpellInstallDir}"
406 lipo -create ${OBJ_LIST} -o lib/${file}
407 # check for the "missing link"...
408 test -f lib/libhunspell.dylib || (cd lib ; ln -s libhunspell-1.2.dylib libhunspell.dylib)
414 for arch in ${ARCH_LIST} ; do
415 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
419 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
420 # we have a private ASpell source tree at hand...
421 # so let's build and install it
422 if [ -z "${ASpellVersion}" ]; then
423 ASpellVersion=`grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
427 ASpellBase="${ASpellName}-${ASpellVersion}"
429 echo Build aspell library ${ASpellBase}
430 echo configure options:
431 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
433 # ASpell builds inplace only :(
434 cd "${ASpellSourceDir}"
436 # ----------------------------------------
437 # Build ASpell for different architectures
438 # ----------------------------------------
439 FILE_LIST="libaspell.15.dylib"
441 for arch in ${ARCH_LIST} ; do
443 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
444 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
445 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
446 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
447 --prefix="${ASpellInstallDir}"\
448 ${AspellConfigureOptions}
449 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
450 make && make install${aspellstrip}
451 for file in ${FILE_LIST} ; do
452 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
453 mv "${ASpellInstallDir}"/lib/${file}\
454 "${ASpellInstallDir}"/lib/${file}-${arch}
456 echo Cannot build and install ASpell for ${arch}.
461 # -------------------------
462 # Create universal binaries
463 # -------------------------
464 for file in ${FILE_LIST} ; do
466 for arch in ${ARCH_LIST} ; do
467 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
470 cd "${ASpellInstallDir}"
471 lipo -create ${OBJ_LIST} -o lib/${file}
477 for arch in ${ARCH_LIST} ; do
478 rm -f "${ASpellInstallDir}"/lib/*-${arch}
486 echo "Frameworks/${1}.framework"
489 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
490 ( cd "${LyxSourceDir}" && sh autogen.sh )
493 FILE_LIST="lyx lyxclient tex2lyx"
494 BUNDLE_PATH="Contents/MacOS"
495 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
498 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
499 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
501 # -------------------------------------
502 # Build LyX for different architectures
503 # -------------------------------------
505 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
506 ASpellFramework=`framework_name Aspell`
507 ASpellFramework=`basename "${ASpellFramework}"`
508 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
509 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
510 LyXConfigureOptions="${LyXConfigureOptions} --with-aspell-framework=${ASpellFramework}"
513 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
514 HunSpellFramework=`framework_name Hunspell`
515 HunSpellFramework=`basename "${HunSpellFramework}"`
516 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
517 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
518 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
520 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
521 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
523 for arch in ${ARCH_LIST} ; do
525 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
526 mkdir "${LyxBuildDir}" && cd "${LyxBuildDir}"
528 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
529 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
530 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
532 echo LDFLAGS="${LDFLAGS}"
533 echo CPPFLAGS="${CPPFLAGS}"
534 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}"
535 "${LyxSourceDir}/configure"\
536 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersion}"\
537 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
538 ${LyXConfigureOptions}\
539 --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \
540 make -j2 && make install${strip}
541 for file in ${FILE_LIST} ; do
542 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
543 mv "${LYX_BUNDLE_PATH}/${file}"\
544 "${LYX_BUNDLE_PATH}/${file}-${arch}"
546 echo ERROR: Cannot build and install LyX for ${arch}.
553 content_directory() {
555 content=`dirname "${target}"`
556 content=`dirname "${content}"`
560 private_framework() {
561 fwdir=`framework_name "$1"`
564 condir=`content_directory "${target}"`
565 libnm=`basename "${source}"`
566 mkdir -p "${condir}/${fwdir}"
567 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
568 cp -p "${source}" "${condir}/${fwdir}"
569 echo Set library id in "${condir}/${fwdir}/${libnm}"
570 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
572 echo Correct library id reference to "${libnm}" in "${target}"
573 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
577 source="${QtInstallDir}"
579 version="Versions/${QtFrameworkVersion}/"
580 condir=`content_directory "${target}"`
581 mkdir -p "${condir}/Resources"
582 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
586 if [ ! -d "${condir}/PlugIns" ]; then
587 mkdir -p "${condir}/PlugIns"
588 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
589 echo Copy plugin "${libname}"
590 dylib=`basename "${libname}"`
591 dirname=`dirname "${libname}"`
592 dirname=`basename "${dirname}"`
593 mkdir -p "${condir}/PlugIns/${dirname}"
594 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
597 for libnm in ${QtLibraries} ; do
598 fwdir=`framework_name "$libnm"`
599 dirname=`dirname "${fwdir}"`
600 mkdir -p "${condir}/${dirname}"
601 dirname=`basename "${fwdir}"`
602 test -d "${condir}/${fwdir}" || (
603 echo Copy framework "${source}/lib/"`basename "${fwdir}"`
604 cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
605 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
606 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
607 find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
608 otool -L "${filename}" 2>/dev/null | while read library ; do
609 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
611 *"${libnm}"*"("*")"*)
612 echo Correct library id reference to "${libnm}" in "${filename}"
613 install_name_tool -change\
614 "${source}/lib/${dirname}/${version}${libnm}"\
615 "@executable_path/../${fwdir}/${version}${libnm}"\
622 echo Correct library id reference to "${libnm}" in "${target}"
623 install_name_tool -change\
624 "${source}/lib/${dirname}/${version}${libnm}"\
625 "@executable_path/../${fwdir}/${version}${libnm}"\
630 # -------------------------
631 # Create universal binaries
632 # -------------------------
633 convert_universal() {
635 for file in ${FILE_LIST} ; do
637 for arch in ${ARCH_LIST} ; do
638 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
639 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
642 if [ -n "${OBJ_LIST}" ]; then
643 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
645 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
646 private_framework Aspell "${ASpellInstallDir}/lib/libaspell.15.dylib" "${LYX_BUNDLE_PATH}/${file}"
648 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
649 private_framework Hunspell "${HunSpellInstallDir}/lib/libhunspell-1.2.0.dylib" "${LYX_BUNDLE_PATH}/${file}"
651 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
652 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
654 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
655 case "${reference}" in
656 *"${LyxBuildDir}"*"("*")")
657 echo ERROR: Bad reference to "${reference}" found!!
662 for arch in ${ARCH_LIST} ; do
663 rm -f ${BUNDLE_PATH}/*-${arch}
667 copy_dictionaries() {
668 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
669 ASpellResources="${LyxAppPrefix}/Contents/Resources"
670 # try to reuse macports dictionaries for now
671 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
672 mkdir -p "${ASpellResources}"
673 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
674 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dict
675 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
676 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dict
678 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
679 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
680 if [ -d "${DictionarySourceDir}" ]; then
681 updateDictionaries "${DictionarySourceDir}"
682 cp -p -r "${DictionarySourceDir}/dict" "${HunSpellResources}"
685 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
686 MyThesResources="${LyxAppPrefix}/Contents/Resources"
687 cp -p -r "${DictionarySourceDir}/thes" "${MyThesResources}"
691 function set_bundle_display_options() {
693 tell application "Finder"
694 set f to POSIX file ("${1}" as string) as alias
697 tell container window
698 set toolbar visible to false
699 set statusbar visible to false
700 set current view to icon view
702 set the bounds to {20, 50, $2, $3}
705 set icon size of the icon view options of container window to 64
706 set arrangement of the icon view options of container window to not arranged
707 set position of item "${LyxName}.app" to {100,$4}
708 set position of item "Applications" to {280,$4}
709 set background picture of the icon view options\
710 of container window to file "background.png" of folder "Pictures"
711 set the bounds of the container window to {0, 0, $2, $3}
712 update without registering applications
721 function make_dmg() {
724 BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
725 BG_W=`echo ${BGSIZE} | awk '{print $1 }'`
726 BG_H=`echo ${BGSIZE} | awk '{h = $2 + 20 ;print h }'`
727 BG_Y=`echo ${BGSIZE} | awk '{y = $2 - 60 ;print y }'`
729 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
731 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
732 # Unmount currently mounted disk image
733 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
735 # Mount the disk image
736 hdiutil attach "${DMGNAME}.sparseimage"
738 # Obtain device information
739 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
740 DEV=$(echo $DEVS | cut -f 1 -d ' ')
741 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
743 # copy in the application bundle
744 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
746 # copy in background image
747 mkdir -p "${VOLUME}/Pictures"
748 cp "${BACKGROUND}" "${VOLUME}/Pictures/background.png"
749 # symlink applications
750 ln -s /Applications/ "${VOLUME}"/Applications
751 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H} ${BG_Y}
752 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
754 # Unmount the disk image
755 hdiutil detach ${DEV}
757 # Convert the disk image to read-only
758 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
759 rm -f "${DMGNAME}.sparseimage"
766 # ------------------------------
767 # Building distribution packages
768 # ------------------------------
770 test -n "${LyxAppZip}" && (
771 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
774 test -n "${DMGLocation}" && (
775 make_dmg "${DMGLocation}"
776 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
777 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
778 echo move to "${DMGLocation}/${DMGNAME}+qt4.dmg"
779 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
780 #for libnm in ${QtLibraries} ; do
781 # fwdir=`framework_name "$libnm"`
782 # rm -rf "${LyxAppDir}.app/Contents/${fwdir}"
784 #make_dmg "${DMGLocation}"