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: July 2014
10 QtAPI=${QtAPI:-"-cocoa"}
11 QtVersion=${QtVersion:-"4.6.3"}
12 QtSourceVersion="qt-everywhere-opensource-src-${QtVersion}"
13 QtBuildSubDir="qt-${QtVersion}-build${QtAPI}"
14 QtConfigureOptions=${QtConfigureOptions:-"-release"}
16 LibMagicVersion=${LibMagicVersion:-"5.19"}
17 LibMagicSource="file-${LibMagicVersion}"
18 LibMagicLibrary="libmagic.1.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 LyXUtilitiesDir=${LyXUtilitiesDir:-"${LyxBuildDir}"/utilities}
30 unset DYLD_LIBRARY_PATH LD_LIBRARY_PATH
33 # * a decent checkout of LyX sources (probably you have it already)
34 # * Qt - build with shared or static libraries for the used platforms (default: i386 and ppc)
35 # or - an unpacked source tree of Qt in $QTSOURCEDIR or in the sibling directory (variable QtSourceVersion)
36 # * for aspell support:
37 # the aspell sources placed in a sibling directory (variable ASpellSource)
38 # * for hunspell support:
39 # the hunspell sources placed in a sibling directory (variable HunSpellSource)
40 # * for dictionary deployment (per default thesauri only):
41 # - aspell: the dictionary files of macports (in /opt/local/share/aspell and /opt/local/lib/aspell-0.60)
42 # - hunspell: the dictionary files in the sibling directory dictionaries/dicts
43 # - mythes: the data and idx files in the sibling directory dictionaries/thes
44 # * for magic file type detection support:
45 # the libmagic sources placed in a sibling directory (variable LibMagicSource)
47 LyXConfigureOptions="--enable-warnings --enable-optimization=-Os --with-x=no"
48 LyXConfigureOptions="${LyXConfigureOptions} --disable-stdlib-debug"
49 AspellConfigureOptions="--enable-warnings --enable-optimization=-O0 --enable-debug --disable-nls --enable-compile-in-filters --disable-pspell-compatibility"
50 HunspellConfigureOptions="--with-warnings --disable-nls --disable-static"
53 QtConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -confirm-license"
54 # stupid special case...
55 case "${QtVersion}:${QtAPI}" in
57 QtConfigureOptions="${QtConfigureOptions} -fast -no-exceptions"
58 QtConfigureOptions="${QtConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
59 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
62 QtConfigureOptions="${QtConfigureOptions} -fast -no-strip"
63 QtConfigureOptions="${QtConfigureOptions} -no-javascript-jit -no-pkg-config"
64 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
68 QtConfigureOptions="${QtConfigureOptions} -no-strip"
69 QtConfigureOptions="${QtConfigureOptions} -no-kms -no-pkg-config"
70 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake tools"
71 QtConfigureOptions="${QtConfigureOptions} -skip qtquick1 -skip qtwebkit -skip qtconnectivity -skip qtscript"
72 QtConfigureOptions="${QtConfigureOptions} -skip qtquickcontrols -skip qtdeclarative"
76 QtConfigureOptions="${QtConfigureOptions} -fast -no-exceptions"
77 QtConfigureOptions="${QtConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
78 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
79 QtConfigureOptions="${QtConfigureOptions} ${QtAPI}"
83 aspell_dictionaries="no"
84 hunspell_dictionaries="yes"
86 libmagic_deployment="yes"
87 aspell_deployment="yes"
88 hunspell_deployment="yes"
89 thesaurus_deployment="yes"
93 # auto detect Xcode location
94 if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
95 DEVELOPER_SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
96 XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
97 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
98 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.7.sdk" # Lion build is default
99 elif [ -d "/Developer/SDKs" ]; then
100 DEVELOPER_SDKS="/Developer/SDKs"
101 XCODE_DEVELOPER="/Developer"
102 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
103 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
106 # detection of script home
107 LyxSourceDir=$(dirname "$0")
108 if [ ! -d "${LyxSourceDir}" ]; then
109 echo Missing LyX source directory.
112 case "${LyxSourceDir}" in
114 LyxSourceDir=$(dirname "${LyxSourceDir}")
118 */development|development)
119 LyxSourceDir=$(dirname "${LyxSourceDir}")
120 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
123 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
128 echo "*" Build script for LyX on Mac OS X
130 echo Optional arguments:
131 echo " --aspell-deployment=yes|no ." default yes
132 echo " --with-qt-frameworks=yes|no." default no
133 echo " --qt-deployment=yes|no ....." default yes
134 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
135 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
136 echo " --with-arch=ARCH ..........." default ppc,i386
137 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
138 echo " --with-dmg-location=PATH ..." default \${build-path}
139 echo " --with-binary-strip=yes ...." default no
141 echo "All other arguments with -- are passed to configure"
142 echo "including the defaults: ${LyXConfigureOptions}"
147 if [ -x "${LyxSourceDir}/configure" ]; then
149 echo "*" Configure options of LyX
151 "${LyxSourceDir}/configure" --help
157 NCPU=$(sysctl -n hw.ncpu)
159 if [ $NCPU -gt 1 ]; then
163 while [ $# -gt 0 ]; do
165 --with-qt-frameworks=*)
166 configure_qt_frameworks=$(echo ${1}|cut -d= -f2)
167 if [ "$configure_qt_frameworks" = "yes" ]; then
174 QTDIR=$(echo ${1}|cut -d= -f2)
177 --with-macosx-target=*)
178 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
182 SDKROOT=$(echo ${1}|cut -d= -f2)
185 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
191 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
199 --libmagic-deployment=*)
200 libmagic_deployment=$(echo ${1}|cut -d= -f2)
203 --aspell-deployment=*)
204 aspell_deployment=$(echo ${1}|cut -d= -f2)
205 aspell_dictionaries=$aspell_deployment
208 --hunspell-deployment=*)
209 hunspell_deployment=$(echo ${1}|cut -d= -f2)
210 hunspell_dictionaries=$hunspell_deployment
213 --thesaurus-deployment=*)
214 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
218 qt_deployment=$(echo ${1}|cut -d= -f2)
222 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
223 ARCH_LIST="${ARCH_LIST} ${ARCH}"
226 --with-dmg-location=*)
227 DMGLocation=$(echo ${1}|cut -d= -f2)
230 --with-binary-strip=yes)
235 LyxBuildDir=$(echo ${1}|cut -d= -f2)
239 LyXUtilitiesDir=$(echo ${1}|cut -d= -f2)
246 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
247 aspell_deployment="no"
251 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
252 hunspell_deployment="no"
256 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
260 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
269 if [ "${configure_qt_frameworks}" != "yes" ]; then
270 QtInstallDir=${QTDIR:-"/opt/qt4"}
273 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
277 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
278 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
280 LibMagicSourceDir=${LIBMAGICDIR:-$(dirname "${LyxSourceDir}")/${LibMagicSource}}
281 LibMagicBuildDir="${LyxBuildDir}"/"${LibMagicSource}"
282 LibMagicInstallDir=${LibMagicInstallDir:-"${LyXUtilitiesDir}"}
283 LibMagicInstallHdr="${LibMagicInstallDir}/include/magic.h"
285 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
286 ASpellBuildDir="${ASpellSourceDir}"
287 ASpellInstallDir=${ASpellInstallDir:-"${LyXUtilitiesDir}"}
288 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
290 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
291 HunSpellBuildDir="${HunSpellSourceDir}"
292 HunSpellInstallDir=${HunSpellInstallDir:-"${LyXUtilitiesDir}"}
293 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
295 QtSourceDir=${QTSOURCEDIR:-$(dirname "${LyxSourceDir}")/${QtSourceVersion}}
296 QtBuildDir=${QtBuildDir:-"${LyxBuildDir}"/${QtBuildSubDir:-"qt-build"}}
298 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
299 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
300 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
302 if [ -z "${LyXVersion}" ]; then
303 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
305 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
308 LyxBase="${LyxName}-${LyXVersion}"
309 LyxApp="${LyxBase}.app"
310 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
311 LyxBuildDir="${LyxAppDir}.build"
312 LyxAppPrefix="${LyxAppDir}.app"
313 # if zip file is needed... remove the comment sign
314 #LyxAppZip="${LyxAppPrefix}.zip"
316 # ---------------------------------
317 # DON'T MODIFY ANYTHING BELOW HERE!
318 # ---------------------------------
320 # don't change order here...
321 case "${QtVersion}" in
323 QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
324 QtFrameworkVersion="5"
327 QtLibraries="QtSvg QtXml QtPrintSupport QtMacExtras QtWidgets QtGui QtNetwork QtConcurrent QtCore"
328 QtFrameworkVersion="5"
331 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
332 QtFrameworkVersion="4"
339 # Check for existing SDKs
340 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
345 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
346 case "${MACOSX_DEPLOYMENT_TARGET}" in
348 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
351 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
356 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
357 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
360 echo Unknown or missing SDK for Mac OS X.
364 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
366 if [ "${configure_qt_frameworks}" != "yes" -a -d "${QtSourceDir}" -a ! \( -d "${QtBuildDir}" -a -d "${QtInstallDir}" \) ]; then
367 echo Build Qt library ${QtSourceDir}
368 if [ "${QtInstallDir}" = "${QtBuildDir}" ]; then
369 echo Bad install directory for Qt.
370 echo Must be different from build directory "${QtBuildDir}".
374 mkdir -p "${QtBuildDir}" && cd "${QtBuildDir}"
375 for arch in ${ARCH_LIST} ; do
376 ARCHS="${ARCHS} -arch ${arch}"
378 echo configure options:
379 echo ${QtConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
380 "${QtSourceDir}"/configure ${QtConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
381 make ${MAKEJOBS} && make install
383 cd "${QtInstallDir}" && (
386 for libnm in ${QtLibraries} ; do
387 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
392 if [ -d "${LibMagicSourceDir}" -a ! -f "${LibMagicInstallHdr}" ]; then
393 # we have a private libmagic (file(1)) source tree at hand...
394 # so let's build and install it
395 if [ -z "${LibMagicVersion}" ]; then
396 LibMagicVersion=$(grep AC_INIT "${LibMagicSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
399 LibMagicName="LibMagic"
400 LibMagicBase="${LibMagicName}-${LibMagicVersion}"
402 echo Build libmagic library ${LibMagicBase}
403 echo configure options:
404 echo --prefix="${LibMagicInstallDir}" ${LibMagicConfigureOptions}
406 mkdir -p "${LibMagicBuildDir}" && cd "${LibMagicBuildDir}"
408 # ----------------------------------------
409 # Build LibMagic for different architectures
410 # ----------------------------------------
411 FILE_LIST="${LibMagicLibrary}"
413 for arch in ${ARCH_LIST} ; do
414 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
415 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
416 "${LibMagicSourceDir}/configure"\
417 --prefix="${LibMagicInstallDir}"\
418 ${LibMagicConfigureOptions}
419 make && make install${strip}
420 for file in ${FILE_LIST} ; do
421 if [ -f "${LibMagicInstallDir}"/lib/${file} ]; then
422 mv "${LibMagicInstallDir}"/lib/${file}\
423 "${LibMagicInstallDir}"/lib/${file}-${arch}
425 echo Cannot build and install LibMagic for ${arch}.
430 # -------------------------
431 # Create universal binaries
432 # -------------------------
433 for file in ${FILE_LIST} ; do
435 for arch in ${ARCH_LIST} ; do
436 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
439 cd "${LibMagicInstallDir}"
440 lipo -create ${OBJ_LIST} -o lib/${file}
446 for arch in ${ARCH_LIST} ; do
447 rm -f "${LibMagicInstallDir}"/lib/*-${arch}
451 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
452 # we have a private HunSpell source tree at hand...
453 # so let's build and install it
454 if [ -z "${HunSpellVersion}" ]; then
455 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
458 HunSpellName="Hunspell"
459 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
461 echo Build hunspell library ${HunSpellBase}
462 echo configure options:
463 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
465 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
467 # ----------------------------------------
468 # Build HunSpell for different architectures
469 # ----------------------------------------
470 FILE_LIST="${HunSpellLibrary}"
472 for arch in ${ARCH_LIST} ; do
474 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
475 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
476 "${HunSpellSourceDir}/configure"\
477 --prefix="${HunSpellInstallDir}"\
478 ${HunspellConfigureOptions}
479 make && make install${strip}
480 for file in ${FILE_LIST} ; do
481 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
482 mv "${HunSpellInstallDir}"/lib/${file}\
483 "${HunSpellInstallDir}"/lib/${file}-${arch}
485 echo Cannot build and install HunSpell for ${arch}.
490 # -------------------------
491 # Create universal binaries
492 # -------------------------
493 for file in ${FILE_LIST} ; do
495 for arch in ${ARCH_LIST} ; do
496 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
499 cd "${HunSpellInstallDir}"
500 lipo -create ${OBJ_LIST} -o lib/${file}
501 # check for the "missing link"...
502 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
508 for arch in ${ARCH_LIST} ; do
509 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
513 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
514 # we have a private ASpell source tree at hand...
515 # so let's build and install it
516 if [ -z "${ASpellVersion}" ]; then
517 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
521 ASpellBase="${ASpellName}-${ASpellVersion}"
523 echo Build aspell library ${ASpellBase}
524 echo configure options:
525 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
527 # ASpell builds inplace only :(
528 cd "${ASpellSourceDir}"
530 # ----------------------------------------
531 # Build ASpell for different architectures
532 # ----------------------------------------
533 FILE_LIST="${ASpellLibrary}"
535 for arch in ${ARCH_LIST} ; do
537 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
538 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
539 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
540 --prefix="${ASpellInstallDir}"\
541 ${AspellConfigureOptions}
542 make && make install${aspellstrip}
543 for file in ${FILE_LIST} ; do
544 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
545 mv "${ASpellInstallDir}"/lib/${file}\
546 "${ASpellInstallDir}"/lib/${file}-${arch}
548 echo Cannot build and install ASpell for ${arch}.
553 # -------------------------
554 # Create universal binaries
555 # -------------------------
556 for file in ${FILE_LIST} ; do
558 for arch in ${ARCH_LIST} ; do
559 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
562 cd "${ASpellInstallDir}"
563 lipo -create ${OBJ_LIST} -o lib/${file}
569 for arch in ${ARCH_LIST} ; do
570 rm -f "${ASpellInstallDir}"/lib/*-${arch}
576 echo "Frameworks/${1}.framework"
579 LYX_FILE_LIST="lyx lyxclient tex2lyx"
580 BUNDLE_PATH="Contents/MacOS"
581 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
584 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
585 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
587 # -------------------------------------
588 # Automate configure check
589 # -------------------------------------
590 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
591 ( cd "${LyxSourceDir}" && sh autogen.sh )
593 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
594 dname=$(dirname "$file")
595 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
596 ( cd "${LyxSourceDir}" && sh autogen.sh )
601 # -------------------------------------
602 # Build LyX for different architectures
603 # -------------------------------------
605 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
606 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
607 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
610 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
611 HunSpellFramework=$(framework_name Hunspell)
612 HunSpellFramework=$(basename "${HunSpellFramework}")
613 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
614 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
615 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
617 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
618 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
620 for arch in ${ARCH_LIST} ; do
622 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
623 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
625 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
626 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
628 if [ "$configure_qt_frameworks" = "yes" ]; then
629 export QT_CORE_CFLAGS="-FQtCore"
630 export QT_CORE_LIBS="-framework QtCore"
631 export QT_FRONTEND_CFLAGS="-FQtGui"
632 export QT_FRONTEND_LIBS="-framework QtGui"
633 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
634 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
637 echo LDFLAGS="${LDFLAGS}"
639 echo CPPFLAGS="${CPPFLAGS}"
641 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"}
642 "${LyxSourceDir}/configure"\
643 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
644 ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"} \
645 ${LyXConfigureOptions}\
646 --enable-build-type=rel && \
647 make ${MAKEJOBS} && make install${strip}
648 for file in ${LYX_FILE_LIST} ; do
649 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
650 mv "${LYX_BUNDLE_PATH}/${file}"\
651 "${LYX_BUNDLE_PATH}/${file}-${arch}"
653 echo ERROR: Cannot build and install LyX for ${arch}.
660 content_directory() {
662 content=$(dirname "${target}")
663 content=$(dirname "${content}")
667 private_framework() {
668 fwdir=$(framework_name "$1")
671 condir=$(content_directory "${target}")
672 libnm=$(basename "${source}")
673 mkdir -p "${condir}/${fwdir}"
674 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
675 cp -p "${source}" "${condir}/${fwdir}"
676 echo Set library id in "${condir}/${fwdir}/${libnm}"
677 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
679 echo Correct library id reference to "${libnm}" in "${target}"
680 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
684 source="${QtInstallDir}"
686 version="Versions/${QtFrameworkVersion}/"
687 condir=$(content_directory "${target}")
688 mkdir -p "${condir}/Resources"
689 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
692 Translations = translations
694 if [ ! -d "${condir}/PlugIns" ]; then
695 mkdir -p "${condir}/PlugIns"
696 find "${source}/plugins" -name \*.dylib -print | grep -v _debug.dylib | while read libname ; do
697 echo Copy plugin "${libname}"
698 dylib=$(basename "${libname}")
699 dirname=$(dirname "${libname}")
700 dirname=$(basename "${dirname}")
701 mkdir -p "${condir}/PlugIns/${dirname}"
702 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
705 for libnm in ${QtLibraries} ; do
706 fwdir=$(framework_name "$libnm")
707 dirname=$(dirname "${fwdir}")
708 mkdir -p "${condir}/${dirname}"
709 dirname=$(basename "${fwdir}")
710 test -d "${condir}/${fwdir}" || (
711 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
712 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
713 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
714 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
715 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
716 if [ "${filename}" != "${target}" ]; then
717 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
718 # pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
720 *"${libnm}"*"("*version*")"*)
721 echo Correct library id reference to "${libnm}" in "${filename}"
722 install_name_tool -change\
723 "${source}/lib/${dirname}/${version}${libnm}"\
724 "@executable_path/../${fwdir}/${version}${libnm}"\
732 echo Correct library id reference to "${libnm}" in "${target}"
733 install_name_tool -change\
734 "${source}/lib/${dirname}/${version}${libnm}"\
735 "@executable_path/../${fwdir}/${version}${libnm}"\
738 if [ ! -d "${condir}/translations" ]; then
739 mkdir -p "${condir}/translations"
741 echo Copy Qt translations to "${condir}/translations"
742 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
745 # -------------------------
746 # Create universal binaries
747 # -------------------------
748 convert_universal() {
750 for file in ${LYX_FILE_LIST} ; do
752 for arch in ${ARCH_LIST} ; do
753 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
754 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
757 if [ -n "${OBJ_LIST}" ]; then
758 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
760 if [ -f "${LibMagicInstallDir}/lib/${LibMagicLibrary}" -a "yes" = "${libmagic_deployment}" ]; then
761 private_framework LibMagic "${LibMagicInstallDir}/lib/${LibMagicLibrary}" "${LYX_BUNDLE_PATH}/${file}"
763 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
764 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
766 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
767 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
769 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
770 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
772 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
773 case "${reference}" in
774 *"${LyxBuildDir}"*"("*")")
775 echo ERROR: Bad reference to "${reference}" found!!
780 for arch in ${ARCH_LIST} ; do
781 rm -f ${BUNDLE_PATH}/*-${arch}
785 copy_dictionaries() {
786 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
787 ASpellResources="${LyxAppPrefix}/Contents/Resources"
788 # try to reuse macports dictionaries for now
789 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
790 mkdir -p "${ASpellResources}"
791 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
792 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
793 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
794 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
796 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
797 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
798 if [ -d "${DictionarySourceDir}" ]; then
799 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
802 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
803 MyThesResources="${LyxAppPrefix}/Contents/Resources"
804 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
808 set_bundle_display_options() {
811 Y_POSITION=$((Y_BOUNDS - 65))
812 Y_BOUNDS=$((Y_BOUNDS + 20))
813 LYX_X_POSITION=$((X_BOUNDS / 4))
814 LYX_Y_POSITION=$Y_POSITION
815 APP_X_POSITION=$((3 * X_BOUNDS / 4))
816 APP_Y_POSITION=$Y_POSITION
817 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
819 tell application "Finder"
820 set f to POSIX file ("${1}" as string) as alias
823 tell container window
824 set toolbar visible to false
825 set statusbar visible to false
826 set current view to icon view
828 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
831 set icon size of the icon view options of container window to 64
832 set arrangement of the icon view options of container window to not arranged
833 if ${WITH_DOCUMENTS} then
834 set position of item "Documents" to {$LYX_X_POSITION,0}
836 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
837 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
838 set background picture of the icon view options\
839 of container window to file "background.png" of folder "Pictures"
840 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
841 update without registering applications
853 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
854 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
855 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
857 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
859 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
860 # Unmount currently mounted disk image
861 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
863 # Mount the disk image
864 hdiutil attach "${DMGNAME}.sparseimage"
866 # Obtain device information
867 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
868 DEV=$(echo $DEVS | cut -f 1 -d ' ')
869 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
871 # copy in the application bundle
872 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
874 # copy in background image
875 mkdir -p "${VOLUME}/Pictures"
876 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
877 # symlink applications
878 ln -s /Applications/ "${VOLUME}"/Applications
879 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
880 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
881 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
882 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
884 # Unmount the disk image
885 hdiutil detach ${DEV}
887 # Convert the disk image to read-only
888 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
889 rm -f "${DMGNAME}.sparseimage"
892 # ------------------------------
893 # Building distribution packages
894 # ------------------------------
897 test -n "${LyxAppZip}" && (
898 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
902 for arch in ${ARCH_LIST} ; do
903 DMGARCH="${DMGARCH}-${arch}"
905 QtDmgArchSuffix=${QtMajorVersion}${DMGARCH}${QtAPI}.dmg
907 test -n "${DMGLocation}" && (
908 make_dmg "${DMGLocation}"
909 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
910 rm -f "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
911 echo move to "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
912 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
917 # ------------------------------
919 # ------------------------------
921 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then