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}
441 # check for the "missing link"...
442 test -f lib/libmagic.dylib || (cd lib ; ln -s "${LibMagicLibrary}" libmagic.dylib)
448 for arch in ${ARCH_LIST} ; do
449 rm -f "${LibMagicInstallDir}"/lib/*-${arch}
453 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
454 # we have a private HunSpell source tree at hand...
455 # so let's build and install it
456 if [ -z "${HunSpellVersion}" ]; then
457 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
460 HunSpellName="Hunspell"
461 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
463 echo Build hunspell library ${HunSpellBase}
464 echo configure options:
465 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
467 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
469 # ----------------------------------------
470 # Build HunSpell for different architectures
471 # ----------------------------------------
472 FILE_LIST="${HunSpellLibrary}"
474 for arch in ${ARCH_LIST} ; do
476 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
477 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
478 "${HunSpellSourceDir}/configure"\
479 --prefix="${HunSpellInstallDir}"\
480 ${HunspellConfigureOptions}
481 make && make install${strip}
482 for file in ${FILE_LIST} ; do
483 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
484 mv "${HunSpellInstallDir}"/lib/${file}\
485 "${HunSpellInstallDir}"/lib/${file}-${arch}
487 echo Cannot build and install HunSpell for ${arch}.
492 # -------------------------
493 # Create universal binaries
494 # -------------------------
495 for file in ${FILE_LIST} ; do
497 for arch in ${ARCH_LIST} ; do
498 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
501 cd "${HunSpellInstallDir}"
502 lipo -create ${OBJ_LIST} -o lib/${file}
503 # check for the "missing link"...
504 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
510 for arch in ${ARCH_LIST} ; do
511 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
515 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
516 # we have a private ASpell source tree at hand...
517 # so let's build and install it
518 if [ -z "${ASpellVersion}" ]; then
519 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
523 ASpellBase="${ASpellName}-${ASpellVersion}"
525 echo Build aspell library ${ASpellBase}
526 echo configure options:
527 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
529 # ASpell builds inplace only :(
530 cd "${ASpellSourceDir}"
532 # ----------------------------------------
533 # Build ASpell for different architectures
534 # ----------------------------------------
535 FILE_LIST="${ASpellLibrary}"
537 for arch in ${ARCH_LIST} ; do
539 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
540 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
541 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
542 --prefix="${ASpellInstallDir}"\
543 ${AspellConfigureOptions}
544 make && make install${aspellstrip}
545 for file in ${FILE_LIST} ; do
546 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
547 mv "${ASpellInstallDir}"/lib/${file}\
548 "${ASpellInstallDir}"/lib/${file}-${arch}
550 echo Cannot build and install ASpell for ${arch}.
555 # -------------------------
556 # Create universal binaries
557 # -------------------------
558 for file in ${FILE_LIST} ; do
560 for arch in ${ARCH_LIST} ; do
561 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
564 cd "${ASpellInstallDir}"
565 lipo -create ${OBJ_LIST} -o lib/${file}
571 for arch in ${ARCH_LIST} ; do
572 rm -f "${ASpellInstallDir}"/lib/*-${arch}
578 echo "Frameworks/${1}.framework"
581 LYX_FILE_LIST="lyx lyxclient tex2lyx"
582 BUNDLE_PATH="Contents/MacOS"
583 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
586 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
587 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
589 # -------------------------------------
590 # Automate configure check
591 # -------------------------------------
592 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
593 ( cd "${LyxSourceDir}" && sh autogen.sh )
595 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
596 dname=$(dirname "$file")
597 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
598 ( cd "${LyxSourceDir}" && sh autogen.sh )
603 # -------------------------------------
604 # Build LyX for different architectures
605 # -------------------------------------
607 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
608 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
609 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
612 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
613 HunSpellFramework=$(framework_name Hunspell)
614 HunSpellFramework=$(basename "${HunSpellFramework}")
615 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
616 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
617 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
619 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
620 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
622 for arch in ${ARCH_LIST} ; do
624 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
625 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
627 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
628 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
630 if [ "$configure_qt_frameworks" = "yes" ]; then
631 export QT_CORE_CFLAGS="-FQtCore"
632 export QT_CORE_LIBS="-framework QtCore"
633 export QT_FRONTEND_CFLAGS="-FQtGui"
634 export QT_FRONTEND_LIBS="-framework QtGui"
635 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
636 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
639 echo LDFLAGS="${LDFLAGS}"
641 echo CPPFLAGS="${CPPFLAGS}"
643 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"}
644 "${LyxSourceDir}/configure"\
645 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
646 ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"} \
647 ${LyXConfigureOptions}\
648 --enable-build-type=rel && \
649 make ${MAKEJOBS} && make install${strip}
650 for file in ${LYX_FILE_LIST} ; do
651 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
652 mv "${LYX_BUNDLE_PATH}/${file}"\
653 "${LYX_BUNDLE_PATH}/${file}-${arch}"
655 echo ERROR: Cannot build and install LyX for ${arch}.
662 content_directory() {
664 content=$(dirname "${target}")
665 content=$(dirname "${content}")
669 private_framework() {
670 fwdir=$(framework_name "$1")
673 condir=$(content_directory "${target}")
674 libnm=$(basename "${source}")
675 mkdir -p "${condir}/${fwdir}"
676 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
677 cp -p "${source}" "${condir}/${fwdir}"
678 echo Set library id in "${condir}/${fwdir}/${libnm}"
679 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
681 echo Correct library id reference to "${libnm}" in "${target}"
682 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
686 source="${QtInstallDir}"
688 version="Versions/${QtFrameworkVersion}/"
689 condir=$(content_directory "${target}")
690 mkdir -p "${condir}/Resources"
691 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
694 Translations = translations
696 if [ ! -d "${condir}/PlugIns" ]; then
697 mkdir -p "${condir}/PlugIns"
698 find "${source}/plugins" -name \*.dylib -print | grep -v _debug.dylib | while read libname ; do
699 echo Copy plugin "${libname}"
700 dylib=$(basename "${libname}")
701 dirname=$(dirname "${libname}")
702 dirname=$(basename "${dirname}")
703 mkdir -p "${condir}/PlugIns/${dirname}"
704 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
707 for libnm in ${QtLibraries} ; do
708 fwdir=$(framework_name "$libnm")
709 dirname=$(dirname "${fwdir}")
710 mkdir -p "${condir}/${dirname}"
711 dirname=$(basename "${fwdir}")
712 test -d "${condir}/${fwdir}" || (
713 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
714 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
715 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
716 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
717 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
718 if [ "${filename}" != "${target}" ]; then
719 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
720 # pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
722 *"${libnm}"*"("*version*")"*)
723 echo Correct library id reference to "${libnm}" in "${filename}"
724 install_name_tool -change\
725 "${source}/lib/${dirname}/${version}${libnm}"\
726 "@executable_path/../${fwdir}/${version}${libnm}"\
734 echo Correct library id reference to "${libnm}" in "${target}"
735 install_name_tool -change\
736 "${source}/lib/${dirname}/${version}${libnm}"\
737 "@executable_path/../${fwdir}/${version}${libnm}"\
740 if [ ! -d "${condir}/translations" ]; then
741 mkdir -p "${condir}/translations"
743 echo Copy Qt translations to "${condir}/translations"
744 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
747 # -------------------------
748 # Create universal binaries
749 # -------------------------
750 convert_universal() {
752 for file in ${LYX_FILE_LIST} ; do
754 for arch in ${ARCH_LIST} ; do
755 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
756 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
759 if [ -n "${OBJ_LIST}" ]; then
760 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
762 if [ -f "${LibMagicInstallDir}/lib/${LibMagicLibrary}" -a "yes" = "${libmagic_deployment}" ]; then
763 private_framework LibMagic "${LibMagicInstallDir}/lib/${LibMagicLibrary}" "${LYX_BUNDLE_PATH}/${file}"
765 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
766 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
768 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
769 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
771 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
772 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
774 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
775 case "${reference}" in
776 *"${LyxBuildDir}"*"("*")")
777 echo ERROR: Bad reference to "${reference}" found!!
782 for arch in ${ARCH_LIST} ; do
783 rm -f ${BUNDLE_PATH}/*-${arch}
787 copy_dictionaries() {
788 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
789 ASpellResources="${LyxAppPrefix}/Contents/Resources"
790 # try to reuse macports dictionaries for now
791 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
792 mkdir -p "${ASpellResources}"
793 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
794 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
795 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
796 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
798 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
799 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
800 if [ -d "${DictionarySourceDir}" ]; then
801 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
804 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
805 MyThesResources="${LyxAppPrefix}/Contents/Resources"
806 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
810 set_bundle_display_options() {
813 Y_POSITION=$((Y_BOUNDS - 65))
814 Y_BOUNDS=$((Y_BOUNDS + 20))
815 LYX_X_POSITION=$((X_BOUNDS / 4))
816 LYX_Y_POSITION=$Y_POSITION
817 APP_X_POSITION=$((3 * X_BOUNDS / 4))
818 APP_Y_POSITION=$Y_POSITION
819 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
821 tell application "Finder"
822 set f to POSIX file ("${1}" as string) as alias
825 tell container window
826 set toolbar visible to false
827 set statusbar visible to false
828 set current view to icon view
830 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
833 set icon size of the icon view options of container window to 64
834 set arrangement of the icon view options of container window to not arranged
835 if ${WITH_DOCUMENTS} then
836 set position of item "Documents" to {$LYX_X_POSITION,0}
838 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
839 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
840 set background picture of the icon view options\
841 of container window to file "background.png" of folder "Pictures"
842 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
843 update without registering applications
855 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
856 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
857 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
859 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
861 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
862 # Unmount currently mounted disk image
863 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
865 # Mount the disk image
866 hdiutil attach "${DMGNAME}.sparseimage"
868 # Obtain device information
869 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
870 DEV=$(echo $DEVS | cut -f 1 -d ' ')
871 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
873 # copy in the application bundle
874 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
876 # copy in background image
877 mkdir -p "${VOLUME}/Pictures"
878 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
879 # symlink applications
880 ln -s /Applications/ "${VOLUME}"/Applications
881 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
882 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
883 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
884 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
886 # Unmount the disk image
887 hdiutil detach ${DEV}
889 # Convert the disk image to read-only
890 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
891 rm -f "${DMGNAME}.sparseimage"
894 # ------------------------------
895 # Building distribution packages
896 # ------------------------------
899 test -n "${LyxAppZip}" && (
900 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
904 for arch in ${ARCH_LIST} ; do
905 DMGARCH="${DMGARCH}-${arch}"
907 QtDmgArchSuffix=${QtMajorVersion}${DMGARCH}${QtAPI}.dmg
909 test -n "${DMGLocation}" && (
910 make_dmg "${DMGLocation}"
911 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
912 rm -f "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
913 echo move to "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
914 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
919 # ------------------------------
921 # ------------------------------
923 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then