5 # This script automates creating universal binaries of LyX on Mac.
6 # Author: Bennett Helm (and extended by Konrad Hofbauer)
7 # latest changes by Stephan Witt
8 # Last modified: January 2013
10 Qt4API=${Qt4API:-"-cocoa"}
11 Qt4Version=${Qt4Version:-"4.6.3"}
12 Qt4SourceVersion="qt-everywhere-opensource-src-${Qt4Version}"
13 Qt4BuildSubDir="qt-${Qt4Version}-build${Qt4API}"
14 Qt4ConfigureOptions=${Qt4ConfigureOptions:-"-release"}
16 GettextVersion=${GettextVersion:-"0.18.2"}
17 GettextSource="gettext-${GettextVersion}"
18 GettextLibrary="libintl.8.dylib"
20 ASpellVersion=${ASpellVersion:-"0.60.6.1"}
21 ASpellSource="aspell-${ASpellVersion}"
22 ASpellLibrary="libaspell.15.dylib"
24 HunSpellVersion=${HunSpellVersion:-"1.3.2"}
25 HunSpellSource="hunspell-${HunSpellVersion}"
26 HunSpellLibrary="libhunspell-1.3.0.dylib"
28 unset DYLD_LIBRARY_PATH LD_LIBRARY_PATH
31 # * a decent checkout of LyX sources (probably you have it already)
32 # * Qt4 - build with shared or static libraries for the used platforms (default: i386 and ppc)
33 # or - an unpacked source tree of Qt4 in $QT4SOURCEDIR or in the sibling directory (variable Qt4SourceVersion)
34 # * for aspell support:
35 # the aspell sources placed in a sibling directory (variable ASpellSource)
36 # * for hunspell support:
37 # the hunspell sources placed in a sibling directory (variable HunSpellSource)
38 # * for dictionary deployment (per default thesauri only):
39 # - aspell: the dictionary files of macports (in /opt/local/share/aspell and /opt/local/lib/aspell-0.60)
40 # - hunspell: the dictionary files in the sibling directory dictionaries/dicts
41 # - mythes: the data and idx files in the sibling directory dictionaries/thes
43 LyXConfigureOptions="--enable-warnings --enable-optimization=-Os --with-x=no"
44 LyXConfigureOptions="${LyXConfigureOptions} --disable-stdlib-debug"
45 AspellConfigureOptions="--enable-warnings --enable-optimization=-O0 --enable-debug --disable-nls --enable-compile-in-filters --disable-pspell-compatibility"
46 HunspellConfigureOptions="--with-warnings --disable-nls --disable-static"
47 Qt4ConfigureOptions="${Qt4ConfigureOptions} -opensource -silent -shared -fast -no-exceptions"
48 Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
49 Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
51 # stupid special case...
52 case "${Qt4Version}:${Qt4API}" in
56 Qt4ConfigureOptions="${Qt4ConfigureOptions} ${Qt4API}"
60 aspell_dictionaries="no"
61 hunspell_dictionaries="yes"
63 gettext_deployment="yes"
64 aspell_deployment="yes"
65 hunspell_deployment="yes"
66 thesaurus_deployment="yes"
70 # auto detect Xcode location
71 if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
72 DEVELOPER_SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
73 XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
74 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
75 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.7.sdk" # Lion build is default
76 elif [ -d "/Developer/SDKs" ]; then
77 DEVELOPER_SDKS="/Developer/SDKs"
78 XCODE_DEVELOPER="/Developer"
79 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
80 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
83 # detection of script home
84 LyxSourceDir=$(dirname "$0")
85 if [ ! -d "${LyxSourceDir}" ]; then
86 echo Missing LyX source directory.
89 case "${LyxSourceDir}" in
91 LyxSourceDir=$(dirname "${LyxSourceDir}")
95 */development|development)
96 LyxSourceDir=$(dirname "${LyxSourceDir}")
97 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
100 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
105 echo "*" Build script for LyX on Mac OS X
107 echo Optional arguments:
108 echo " --aspell-deployment=yes|no ." default yes
109 echo " --with-qt4-frameworks=yes|no" default no
110 echo " --qt4-deployment=yes|no ...." default yes
111 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
112 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
113 echo " --with-arch=ARCH ..........." default ppc,i386
114 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
115 echo " --with-dmg-location=PATH ..." default \${build-path}
117 echo "All other arguments with -- are passed to configure"
118 echo "including the defaults: ${LyXConfigureOptions}"
119 if [ -x "${LyxSourceDir}/configure" ]; then
121 echo "*" Configure options of LyX
123 "${LyxSourceDir}/configure" --help
128 while [ $# -gt 0 ]; do
130 --with-qt4-frameworks=*)
131 configure_qt4_frameworks=$(echo ${1}|cut -d= -f2)
132 if [ "$configure_qt4_frameworks" = "yes" ]; then
139 QTDIR=$(echo ${1}|cut -d= -f2)
142 --with-macosx-target=*)
143 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
147 SDKROOT=$(echo ${1}|cut -d= -f2)
150 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
156 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
164 --gettext-deployment=*)
165 gettext_deployment=$(echo ${1}|cut -d= -f2)
168 --aspell-deployment=*)
169 aspell_deployment=$(echo ${1}|cut -d= -f2)
170 aspell_dictionaries=$aspell_deployment
173 --hunspell-deployment=*)
174 hunspell_deployment=$(echo ${1}|cut -d= -f2)
175 hunspell_dictionaries=$hunspell_deployment
178 --thesaurus-deployment=*)
179 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
183 qt4_deployment=$(echo ${1}|cut -d= -f2)
187 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
188 ARCH_LIST="${ARCH_LIST} ${ARCH}"
191 --with-dmg-location=*)
192 DMGLocation=$(echo ${1}|cut -d= -f2)
196 LyxBuildDir=$(echo ${1}|cut -d= -f2)
203 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
204 aspell_deployment="no"
208 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
209 hunspell_deployment="no"
213 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
217 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
226 if [ "${configure_qt4_frameworks}" != "yes" ]; then
227 QtInstallDir=${QTDIR:-"/opt/qt4"}
229 QtFrameworkVersion="4"
231 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
236 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
237 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
239 GettextSourceDir=${GETTEXTDIR:-$(dirname "${LyxSourceDir}")/${GettextSource}}
240 GettextBuildDir="${LyxBuildDir}"/"${GettextSource}"
241 GettextInstallDir=${GettextInstallDir:-"${LyxBuildDir}"/utilities}
242 GettextInstallHdr="${GettextInstallDir}/include/libintl.h"
244 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
245 ASpellBuildDir="${ASpellSourceDir}"
246 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/utilities}
247 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
249 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
250 HunSpellBuildDir="${HunSpellSourceDir}"
251 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/utilities}
252 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
254 Qt4SourceDir=${QT4SOURCEDIR:-$(dirname "${LyxSourceDir}")/${Qt4SourceVersion}}
255 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4BuildSubDir:-"qt4-build"}}
257 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
258 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
259 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
261 if [ -z "${LyXVersion}" ]; then
262 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
264 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
267 LyxBase="${LyxName}-${LyXVersion}"
268 LyxApp="${LyxBase}.app"
269 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
270 LyxBuildDir="${LyxAppDir}.build"
271 LyxAppPrefix="${LyxAppDir}.app"
272 # if zip file is needed... remove the comment sign
273 #LyxAppZip="${LyxAppPrefix}.zip"
275 # ---------------------------------
276 # DON'T MODIFY ANYTHING BELOW HERE!
277 # ---------------------------------
279 # don't change order here...
280 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
285 # Check for existing SDKs
286 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
291 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
292 case "${MACOSX_DEPLOYMENT_TARGET}" in
294 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
297 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
302 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
303 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
306 echo Unknown or missing SDK for Mac OS X.
310 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
312 # These variables define the identifiers of the
313 # system (both Intel and PowerPC) to compile for.
314 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
315 # Only change these if necessary
317 HostSystem_i386="i686-apple-darwin8"
318 HostSystem_ppc="powerpc-apple-darwin8"
320 if [ "${configure_qt4_frameworks}" != "yes" -a -d "${Qt4SourceDir}" -a ! \( -d "${Qt4BuildDir}" -a -d "${QtInstallDir}" \) ]; then
321 echo Build Qt4 library ${Qt4SourceDir}
322 if [ "${QtInstallDir}" = "${Qt4BuildDir}" ]; then
323 echo Bad install directory for Qt.
324 echo Must be different from build directory "${Qt4BuildDir}".
328 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
329 for arch in ${ARCH_LIST} ; do
330 ARCHS="${ARCHS} -arch ${arch}"
332 echo configure options:
333 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
334 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
337 cd "${QtInstallDir}" && (
340 for libnm in ${QtLibraries} ; do
341 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
346 if [ -d "${GettextSourceDir}" -a ! -f "${GettextInstallHdr}" ]; then
347 # we have a private Gettext source tree at hand...
348 # so let's build and install it
349 if [ -z "${GettextVersion}" ]; then
350 GettextVersion=$(grep AC_INIT "${GettextSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
353 GettextName="Gettext"
354 GettextBase="${GettextName}-${GettextVersion}"
356 echo Build gettext library ${GettextBase}
357 echo configure options:
358 echo --prefix="${GettextInstallDir}" ${GettextConfigureOptions}
360 mkdir -p "${GettextBuildDir}" && cd "${GettextBuildDir}"
362 # ----------------------------------------
363 # Build Gettext for different architectures
364 # ----------------------------------------
365 FILE_LIST="${GettextLibrary}"
367 for arch in ${ARCH_LIST} ; do
368 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
369 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
370 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
371 "${GettextSourceDir}/configure"\
372 --prefix="${GettextInstallDir}"\
373 ${GettextConfigureOptions}
374 make && make install${strip}
375 for file in ${FILE_LIST} ; do
376 if [ -f "${GettextInstallDir}"/lib/${file} ]; then
377 mv "${GettextInstallDir}"/lib/${file}\
378 "${GettextInstallDir}"/lib/${file}-${arch}
380 echo Cannot build and install Gettext for ${arch}.
385 # -------------------------
386 # Create universal binaries
387 # -------------------------
388 for file in ${FILE_LIST} ; do
390 for arch in ${ARCH_LIST} ; do
391 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
394 cd "${GettextInstallDir}"
395 lipo -create ${OBJ_LIST} -o lib/${file}
401 for arch in ${ARCH_LIST} ; do
402 rm -f "${GettextInstallDir}"/lib/*-${arch}
406 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
407 # we have a private HunSpell source tree at hand...
408 # so let's build and install it
409 if [ -z "${HunSpellVersion}" ]; then
410 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
413 HunSpellName="Hunspell"
414 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
416 echo Build hunspell library ${HunSpellBase}
417 echo configure options:
418 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
420 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
422 # ----------------------------------------
423 # Build HunSpell for different architectures
424 # ----------------------------------------
425 FILE_LIST="${HunSpellLibrary}"
427 for arch in ${ARCH_LIST} ; do
429 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
430 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
431 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
432 "${HunSpellSourceDir}/configure"\
433 --prefix="${HunSpellInstallDir}"\
434 ${HunspellConfigureOptions}
435 make && make install${strip}
436 for file in ${FILE_LIST} ; do
437 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
438 mv "${HunSpellInstallDir}"/lib/${file}\
439 "${HunSpellInstallDir}"/lib/${file}-${arch}
441 echo Cannot build and install HunSpell for ${arch}.
446 # -------------------------
447 # Create universal binaries
448 # -------------------------
449 for file in ${FILE_LIST} ; do
451 for arch in ${ARCH_LIST} ; do
452 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
455 cd "${HunSpellInstallDir}"
456 lipo -create ${OBJ_LIST} -o lib/${file}
457 # check for the "missing link"...
458 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
464 for arch in ${ARCH_LIST} ; do
465 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
469 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
470 # we have a private ASpell source tree at hand...
471 # so let's build and install it
472 if [ -z "${ASpellVersion}" ]; then
473 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
477 ASpellBase="${ASpellName}-${ASpellVersion}"
479 echo Build aspell library ${ASpellBase}
480 echo configure options:
481 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
483 # ASpell builds inplace only :(
484 cd "${ASpellSourceDir}"
486 # ----------------------------------------
487 # Build ASpell for different architectures
488 # ----------------------------------------
489 FILE_LIST="${ASpellLibrary}"
491 for arch in ${ARCH_LIST} ; do
493 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
494 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
495 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
496 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
497 --prefix="${ASpellInstallDir}"\
498 ${AspellConfigureOptions}
499 make && make install${aspellstrip}
500 for file in ${FILE_LIST} ; do
501 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
502 mv "${ASpellInstallDir}"/lib/${file}\
503 "${ASpellInstallDir}"/lib/${file}-${arch}
505 echo Cannot build and install ASpell for ${arch}.
510 # -------------------------
511 # Create universal binaries
512 # -------------------------
513 for file in ${FILE_LIST} ; do
515 for arch in ${ARCH_LIST} ; do
516 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
519 cd "${ASpellInstallDir}"
520 lipo -create ${OBJ_LIST} -o lib/${file}
526 for arch in ${ARCH_LIST} ; do
527 rm -f "${ASpellInstallDir}"/lib/*-${arch}
533 echo "Frameworks/${1}.framework"
536 LYX_FILE_LIST="lyx lyxclient tex2lyx"
537 BUNDLE_PATH="Contents/MacOS"
538 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
541 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
542 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
544 # -------------------------------------
545 # Automate configure check
546 # -------------------------------------
547 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
548 ( cd "${LyxSourceDir}" && sh autogen.sh )
550 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
551 dname=$(dirname "$file")
552 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
553 ( cd "${LyxSourceDir}" && sh autogen.sh )
558 # -------------------------------------
559 # Build LyX for different architectures
560 # -------------------------------------
562 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
563 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
564 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
567 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
568 HunSpellFramework=$(framework_name Hunspell)
569 HunSpellFramework=$(basename "${HunSpellFramework}")
570 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
571 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
572 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
574 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
575 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
577 for arch in ${ARCH_LIST} ; do
579 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
580 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
582 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
583 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
584 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
586 if [ "$configure_qt4_frameworks" = "yes" ]; then
587 export QT4_CORE_CFLAGS="-FQtCore"
588 export QT4_CORE_LIBS="-framework QtCore"
589 export QT4_FRONTEND_CFLAGS="-FQtGui"
590 export QT4_FRONTEND_LIBS="-framework QtGui"
592 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
593 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
596 echo LDFLAGS="${LDFLAGS}"
598 echo CPPFLAGS="${CPPFLAGS}"
600 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"}
601 "${LyxSourceDir}/configure"\
602 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
603 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
604 ${LyXConfigureOptions}\
605 --enable-build-type=rel && \
606 NCPU=$(sysctl -n hw.ncpu)
608 if [ $NCPU -gt 1 ]; then
611 make ${NUMJOBS} && make install${strip}
612 for file in ${LYX_FILE_LIST} ; do
613 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
614 mv "${LYX_BUNDLE_PATH}/${file}"\
615 "${LYX_BUNDLE_PATH}/${file}-${arch}"
617 echo ERROR: Cannot build and install LyX for ${arch}.
624 content_directory() {
626 content=$(dirname "${target}")
627 content=$(dirname "${content}")
631 private_framework() {
632 fwdir=$(framework_name "$1")
635 condir=$(content_directory "${target}")
636 libnm=$(basename "${source}")
637 mkdir -p "${condir}/${fwdir}"
638 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
639 cp -p "${source}" "${condir}/${fwdir}"
640 echo Set library id in "${condir}/${fwdir}/${libnm}"
641 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
643 echo Correct library id reference to "${libnm}" in "${target}"
644 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
648 source="${QtInstallDir}"
650 version="Versions/${QtFrameworkVersion}/"
651 condir=$(content_directory "${target}")
652 mkdir -p "${condir}/Resources"
653 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
656 Translations = translations
658 if [ ! -d "${condir}/PlugIns" ]; then
659 mkdir -p "${condir}/PlugIns"
660 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
661 echo Copy plugin "${libname}"
662 dylib=$(basename "${libname}")
663 dirname=$(dirname "${libname}")
664 dirname=$(basename "${dirname}")
665 mkdir -p "${condir}/PlugIns/${dirname}"
666 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
669 for libnm in ${QtLibraries} ; do
670 fwdir=$(framework_name "$libnm")
671 dirname=$(dirname "${fwdir}")
672 mkdir -p "${condir}/${dirname}"
673 dirname=$(basename "${fwdir}")
674 test -d "${condir}/${fwdir}" || (
675 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
676 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
677 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
678 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
679 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
680 if [ "${filename}" != "${target}" ]; then
681 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
682 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
684 *"${libnm}"*"("*version*")"*)
685 echo Correct library id reference to "${libnm}" in "${filename}"
686 install_name_tool -change\
687 "${source}/lib/${dirname}/${version}${libnm}"\
688 "@executable_path/../${fwdir}/${version}${libnm}"\
696 echo Correct library id reference to "${libnm}" in "${target}"
697 install_name_tool -change\
698 "${source}/lib/${dirname}/${version}${libnm}"\
699 "@executable_path/../${fwdir}/${version}${libnm}"\
702 if [ ! -d "${condir}/translations" ]; then
703 mkdir -p "${condir}/translations"
705 echo Copy Qt translations to "${condir}/translations"
706 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
709 # -------------------------
710 # Create universal binaries
711 # -------------------------
712 convert_universal() {
714 for file in ${LYX_FILE_LIST} ; do
716 for arch in ${ARCH_LIST} ; do
717 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
718 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
721 if [ -n "${OBJ_LIST}" ]; then
722 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
724 if [ -f "${GettextInstallDir}/lib/${GettextLibrary}" -a "yes" = "${gettext_deployment}" ]; then
725 private_framework Gettext "${GettextInstallDir}/lib/${GettextLibrary}" "${LYX_BUNDLE_PATH}/${file}"
727 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
728 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
730 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
731 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
733 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
734 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
736 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
737 case "${reference}" in
738 *"${LyxBuildDir}"*"("*")")
739 echo ERROR: Bad reference to "${reference}" found!!
744 for arch in ${ARCH_LIST} ; do
745 rm -f ${BUNDLE_PATH}/*-${arch}
749 copy_dictionaries() {
750 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
751 ASpellResources="${LyxAppPrefix}/Contents/Resources"
752 # try to reuse macports dictionaries for now
753 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
754 mkdir -p "${ASpellResources}"
755 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
756 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
757 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
758 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
760 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
761 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
762 if [ -d "${DictionarySourceDir}" ]; then
763 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
766 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
767 MyThesResources="${LyxAppPrefix}/Contents/Resources"
768 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
772 set_bundle_display_options() {
775 Y_POSITION=$((Y_BOUNDS - 65))
776 Y_BOUNDS=$((Y_BOUNDS + 20))
777 LYX_X_POSITION=$((X_BOUNDS / 4))
778 LYX_Y_POSITION=$Y_POSITION
779 APP_X_POSITION=$((3 * X_BOUNDS / 4))
780 APP_Y_POSITION=$Y_POSITION
782 tell application "Finder"
783 set f to POSIX file ("${1}" as string) as alias
786 tell container window
787 set toolbar visible to false
788 set statusbar visible to false
789 set current view to icon view
791 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
794 set icon size of the icon view options of container window to 64
795 set arrangement of the icon view options of container window to not arranged
796 set position of item "Documents" to {$LYX_X_POSITION,0}
797 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
798 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
799 set background picture of the icon view options\
800 of container window to file "background.png" of folder "Pictures"
801 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
802 update without registering applications
814 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
815 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
816 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
818 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
820 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
821 # Unmount currently mounted disk image
822 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
824 # Mount the disk image
825 hdiutil attach "${DMGNAME}.sparseimage"
827 # Obtain device information
828 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
829 DEV=$(echo $DEVS | cut -f 1 -d ' ')
830 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
832 # copy in the application bundle
833 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
835 # copy in background image
836 mkdir -p "${VOLUME}/Pictures"
837 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
838 # symlink applications
839 ln -s /Applications/ "${VOLUME}"/Applications
840 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
841 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
842 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
843 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
845 # Unmount the disk image
846 hdiutil detach ${DEV}
848 # Convert the disk image to read-only
849 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
850 rm -f "${DMGNAME}.sparseimage"
853 # ------------------------------
854 # Building distribution packages
855 # ------------------------------
858 test -n "${LyxAppZip}" && (
859 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
862 test -n "${DMGLocation}" && (
863 make_dmg "${DMGLocation}"
864 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
865 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
866 echo move to "${DMGLocation}/${DMGNAME}+qt4${Qt4API}.dmg"
867 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4${Qt4API}.dmg"
872 # ------------------------------
874 # ------------------------------
876 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then