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 unset DYLD_LIBRARY_PATH LD_LIBRARY_PATH
31 # * a decent checkout of LyX sources (probably you have it already)
32 # * Qt - build with shared or static libraries for the used platforms (default: i386 and ppc)
33 # or - an unpacked source tree of Qt in $QTSOURCEDIR or in the sibling directory (variable QtSourceVersion)
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 (only hunspell dicts and mythes thesauri are deployed per default):
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
42 # * for magic file type detection support:
43 # the libmagic sources placed in a sibling directory (variable LibMagicSource)
45 LyXConfigureOptions="--enable-warnings --enable-optimization=-Os --with-x=no"
46 LyXConfigureOptions="${LyXConfigureOptions} --disable-stdlib-debug"
47 AspellConfigureOptions="--enable-warnings --enable-optimization=-O0 --enable-debug --disable-nls --enable-compile-in-filters --disable-pspell-compatibility"
48 HunspellConfigureOptions="--with-warnings --disable-nls --disable-static"
51 QtConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -confirm-license"
52 # stupid special case...
53 case "${QtVersion}:${QtAPI}" in
55 QtConfigureOptions="${QtConfigureOptions} -fast -no-exceptions"
56 QtConfigureOptions="${QtConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
57 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
58 for arch in ${ARCH_LIST} ; do
59 QTARCHS="${QTARCHS} -arch ${arch}"
63 QtConfigureOptions="${QtConfigureOptions} -fast -no-strip"
64 QtConfigureOptions="${QtConfigureOptions} -no-javascript-jit -no-pkg-config"
65 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
69 QtConfigureOptions="${QtConfigureOptions} -no-strip"
70 QtConfigureOptions="${QtConfigureOptions} -no-kms -no-pkg-config"
71 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake tools"
72 QtConfigureOptions="${QtConfigureOptions} -skip qtconnectivity -skip qtscript"
73 QtConfigureOptions="${QtConfigureOptions} -skip qtquickcontrols -skip qtdeclarative"
77 QtConfigureOptions="${QtConfigureOptions} -no-strip"
78 QtConfigureOptions="${QtConfigureOptions} -no-kms -no-pkg-config"
79 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake tools"
80 QtConfigureOptions="${QtConfigureOptions} -skip qtquick1 -skip qtwebkit -skip qtconnectivity -skip qtscript"
81 QtConfigureOptions="${QtConfigureOptions} -skip qtquickcontrols"
82 # QtConfigureOptions="${QtConfigureOptions} -skip qtdeclarative"
86 QtConfigureOptions="${QtConfigureOptions} -fast -no-exceptions"
87 QtConfigureOptions="${QtConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
88 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
89 QtConfigureOptions="${QtConfigureOptions} ${QtAPI}"
90 for arch in ${ARCH_LIST} ; do
91 QTARCHS="${QTARCHS} -arch ${arch}"
96 aspell_dictionaries="no"
97 hunspell_dictionaries="yes"
99 libmagic_deployment="yes"
100 aspell_deployment="yes"
101 hunspell_deployment="yes"
102 thesaurus_deployment="yes"
106 # auto detect Xcode location
107 DEVELOPER_SDKS=$(dirname $(xcrun --show-sdk-path))
108 if [ -n "${DEVELOPER_SDKS}" ]; then
109 XCODE_DEVELOPER=$(dirname $(dirname $(xcrun --show-sdk-platform-path)))
110 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
111 SDKROOT="${DEVELOPER_SDKS}/MacOSX$(xcrun --show-sdk-version).sdk" # use default SDK
112 elif [ -d "/Developer/SDKs" ]; then
113 DEVELOPER_SDKS="/Developer/SDKs"
114 XCODE_DEVELOPER="/Developer"
115 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
116 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
119 # detection of script home
120 LyxSourceDir=$(dirname "$0")
121 if [ ! -d "${LyxSourceDir}" ]; then
122 echo Missing LyX source directory.
125 case "${LyxSourceDir}" in
127 LyxSourceDir=$(dirname "${LyxSourceDir}")
131 */development|development)
132 LyxSourceDir=$(dirname "${LyxSourceDir}")
133 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
136 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
141 echo "*" Build script for LyX on Mac OS X
143 echo Optional arguments:
144 echo " --aspell-deployment=yes|no ." default yes
145 echo " --with-qt-frameworks=yes|no." default no
146 echo " --qt-deployment=yes|no ....." default yes
147 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
148 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
149 echo " --with-arch=ARCH ..........." default ppc,i386
150 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
151 echo " --with-dmg-location=PATH ..." default \${build-path}
152 echo " --with-binary-strip=yes ...." default no
154 echo "All other arguments with -- are passed to configure"
155 echo "including the defaults: ${LyXConfigureOptions}"
160 if [ -x "${LyxSourceDir}/configure" ]; then
162 echo "*" Configure options of LyX
164 "${LyxSourceDir}/configure" --help
170 NCPU=$(sysctl -n hw.ncpu)
172 if [ $NCPU -gt 1 ]; then
176 while [ $# -gt 0 ]; do
178 --with-qt-frameworks=*)
179 configure_qt_frameworks=$(echo ${1}|cut -d= -f2)
180 if [ "$configure_qt_frameworks" = "yes" ]; then
187 QTDIR=$(echo ${1}|cut -d= -f2)
190 --with-macosx-target=*)
191 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
195 SDKROOT=$(echo ${1}|cut -d= -f2)
198 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
204 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
205 if [ ! -d "${SDKROOT}" ]; then
206 echo Invalid SDKROOT given: "${SDKROOT}"
213 --libmagic-deployment=*)
214 libmagic_deployment=$(echo ${1}|cut -d= -f2)
217 --aspell-deployment=*)
218 aspell_deployment=$(echo ${1}|cut -d= -f2)
219 aspell_dictionaries=$aspell_deployment
222 --hunspell-deployment=*)
223 hunspell_deployment=$(echo ${1}|cut -d= -f2)
224 hunspell_dictionaries=$hunspell_deployment
227 --thesaurus-deployment=*)
228 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
232 qt_deployment=$(echo ${1}|cut -d= -f2)
236 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
237 ARCH_LIST="${ARCH_LIST} ${ARCH}"
240 --with-dmg-location=*)
241 DMGLocation=$(echo ${1}|cut -d= -f2)
244 --with-binary-strip=yes)
249 LyxBuildDir=$(echo ${1}|cut -d= -f2)
253 LyXUtilitiesDir=$(echo ${1}|cut -d= -f2)
260 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
261 aspell_deployment="no"
265 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
266 hunspell_deployment="no"
270 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
274 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
283 if [ "${configure_qt_frameworks}" != "yes" ]; then
284 QtInstallDir=${QTDIR:-"/opt/qt4"}
287 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
291 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
292 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
294 LyXUtilitiesDir=${LyXUtilitiesDir:-"${LyxBuildDir}"/utilities}
296 LibMagicSourceDir=${LIBMAGICDIR:-$(dirname "${LyxSourceDir}")/${LibMagicSource}}
297 LibMagicBuildDir="${LyxBuildDir}"/"${LibMagicSource}"
298 LibMagicInstallDir=${LibMagicInstallDir:-"${LyXUtilitiesDir}"}
299 LibMagicInstallHdr="${LibMagicInstallDir}/include/magic.h"
301 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
302 ASpellBuildDir="${ASpellSourceDir}"
303 ASpellInstallDir=${ASpellInstallDir:-"${LyXUtilitiesDir}"}
304 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
306 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
307 HunSpellBuildDir="${HunSpellSourceDir}"
308 HunSpellInstallDir=${HunSpellInstallDir:-"${LyXUtilitiesDir}"}
309 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
311 QtSourceDir=${QTSOURCEDIR:-$(dirname "${LyxSourceDir}")/${QtSourceVersion}}
312 QtBuildDir=${QtBuildDir:-"${LyxBuildDir}"/${QtBuildSubDir:-"qt-build"}}
314 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
315 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
316 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
318 if [ -z "${LyXVersion}" ]; then
319 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
321 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
322 case "${LyXVersion}" in
324 LyXGitCommitHash=$(cd "${LyxSourceDir}" ; git log -1 --pretty=format:%h)
329 LyxBase="${LyxName}-${LyXVersion}"
330 LyxApp="${LyxBase}.app"
331 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
332 LyxBuildDir="${LyxAppDir}.build"
333 LyxAppPrefix="${LyxAppDir}.app"
334 # if zip file is needed... remove the comment sign
335 #LyxAppZip="${LyxAppPrefix}.zip"
337 # ---------------------------------
338 # DON'T MODIFY ANYTHING BELOW HERE!
339 # ---------------------------------
341 # don't change order here...
342 case "${QtVersion}" in
344 QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
345 QtFrameworkVersion="5"
348 QtLibraries="QtSvg QtXml QtPrintSupport QtMacExtras QtWidgets QtGui QtNetwork QtConcurrent QtCore"
349 QtFrameworkVersion="5"
352 QtLibraries="QtSvg QtXml QtPrintSupport QtDBus QtMacExtras QtWidgets QtGui QtNetwork QtConcurrent QtCore"
353 QtFrameworkVersion="5"
356 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
357 QtFrameworkVersion="4"
361 DMGNAME="${LyxBase}${LyXGitCommitHash:+-}${LyXGitCommitHash}"
364 # Check for existing SDKs
365 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
370 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
371 case "${MACOSX_DEPLOYMENT_TARGET}" in
373 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
376 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
381 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
382 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
385 echo Unknown or missing SDK for Mac OS X.
389 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
391 if [ "${configure_qt_frameworks}" != "yes" -a -d "${QtSourceDir}" -a ! \( -d "${QtBuildDir}" -a -d "${QtInstallDir}" \) ]; then
392 echo Build Qt library ${QtSourceDir}
393 if [ "${QtInstallDir}" = "${QtBuildDir}" ]; then
394 echo Bad install directory for Qt.
395 echo Must be different from build directory "${QtBuildDir}".
399 mkdir -p "${QtBuildDir}" && cd "${QtBuildDir}"
400 echo configure options:
401 echo ${QtConfigureOptions} ${QTARCHS} -prefix "${QtInstallDir}"
402 "${QtSourceDir}"/configure ${QtConfigureOptions} ${QTARCHS} -prefix "${QtInstallDir}"
403 make -j1 && make -j1 install
406 if [ -d "${QtInstallDir}" -a ! -f "${QtInstallDir}"/include/QtCore ]; then
407 cd "${QtInstallDir}" && (
410 for libnm in ${QtLibraries} ; do
411 test -d ${libnm} -o -L ${libnm} || \
412 ( ln -s ../lib/${libnm}.framework/Headers ${libnm} && echo Link to framework ${libnm} )
417 if [ -d "${LibMagicSourceDir}" -a ! -f "${LibMagicInstallHdr}" ]; then
418 # we have a private libmagic (file(1)) source tree at hand...
419 # so let's build and install it
420 if [ -z "${LibMagicVersion}" ]; then
421 LibMagicVersion=$(grep AC_INIT "${LibMagicSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
424 LibMagicName="LibMagic"
425 LibMagicBase="${LibMagicName}-${LibMagicVersion}"
427 echo Build libmagic library ${LibMagicBase}
428 echo configure options:
429 echo --prefix="${LibMagicInstallDir}" ${LibMagicConfigureOptions}
431 mkdir -p "${LibMagicBuildDir}" && cd "${LibMagicBuildDir}"
433 # ----------------------------------------
434 # Build LibMagic for different architectures
435 # ----------------------------------------
436 FILE_LIST="${LibMagicLibrary}"
438 for arch in ${ARCH_LIST} ; do
439 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
440 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
441 "${LibMagicSourceDir}/configure"\
442 --prefix="${LibMagicInstallDir}"\
443 ${LibMagicConfigureOptions}
444 make && make install${strip}
445 for file in ${FILE_LIST} ; do
446 if [ -f "${LibMagicInstallDir}"/lib/${file} ]; then
447 mv "${LibMagicInstallDir}"/lib/${file}\
448 "${LibMagicInstallDir}"/lib/${file}-${arch}
450 echo Cannot build and install LibMagic for ${arch}.
455 # -------------------------
456 # Create universal binaries
457 # -------------------------
458 for file in ${FILE_LIST} ; do
460 for arch in ${ARCH_LIST} ; do
461 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
464 cd "${LibMagicInstallDir}"
465 lipo -create ${OBJ_LIST} -o lib/${file}
466 # check for the "missing link"...
467 test -f lib/libmagic.dylib || (cd lib ; ln -s "${LibMagicLibrary}" libmagic.dylib)
473 for arch in ${ARCH_LIST} ; do
474 rm -f "${LibMagicInstallDir}"/lib/*-${arch}
478 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
479 # we have a private HunSpell source tree at hand...
480 # so let's build and install it
481 if [ -z "${HunSpellVersion}" ]; then
482 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
485 HunSpellName="Hunspell"
486 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
488 echo Build hunspell library ${HunSpellBase}
489 echo configure options:
490 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
492 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
494 # ----------------------------------------
495 # Build HunSpell for different architectures
496 # ----------------------------------------
497 FILE_LIST="${HunSpellLibrary}"
499 for arch in ${ARCH_LIST} ; do
501 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
502 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
503 "${HunSpellSourceDir}/configure"\
504 --prefix="${HunSpellInstallDir}"\
505 ${HunspellConfigureOptions}
506 make && make install${strip}
507 for file in ${FILE_LIST} ; do
508 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
509 mv "${HunSpellInstallDir}"/lib/${file}\
510 "${HunSpellInstallDir}"/lib/${file}-${arch}
512 echo Cannot build and install HunSpell for ${arch}.
517 # -------------------------
518 # Create universal binaries
519 # -------------------------
520 for file in ${FILE_LIST} ; do
522 for arch in ${ARCH_LIST} ; do
523 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
526 cd "${HunSpellInstallDir}"
527 lipo -create ${OBJ_LIST} -o lib/${file}
528 # check for the "missing link"...
529 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
535 for arch in ${ARCH_LIST} ; do
536 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
540 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
541 # we have a private ASpell source tree at hand...
542 # so let's build and install it
543 if [ -z "${ASpellVersion}" ]; then
544 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
548 ASpellBase="${ASpellName}-${ASpellVersion}"
550 echo Build aspell library ${ASpellBase}
551 echo configure options:
552 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
554 # ASpell builds inplace only :(
555 cd "${ASpellSourceDir}"
557 # ----------------------------------------
558 # Build ASpell for different architectures
559 # ----------------------------------------
560 FILE_LIST="${ASpellLibrary}"
562 for arch in ${ARCH_LIST} ; do
564 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
565 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
566 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
567 --prefix="${ASpellInstallDir}"\
568 ${AspellConfigureOptions}
569 make && make install${aspellstrip}
570 for file in ${FILE_LIST} ; do
571 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
572 mv "${ASpellInstallDir}"/lib/${file}\
573 "${ASpellInstallDir}"/lib/${file}-${arch}
575 echo Cannot build and install ASpell for ${arch}.
580 # -------------------------
581 # Create universal binaries
582 # -------------------------
583 for file in ${FILE_LIST} ; do
585 for arch in ${ARCH_LIST} ; do
586 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
589 cd "${ASpellInstallDir}"
590 lipo -create ${OBJ_LIST} -o lib/${file}
596 for arch in ${ARCH_LIST} ; do
597 rm -f "${ASpellInstallDir}"/lib/*-${arch}
603 echo "Frameworks/${1}.framework"
606 LYX_FILE_LIST="lyx lyxclient tex2lyx"
607 BUNDLE_PATH="Contents/MacOS"
608 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
611 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
612 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
614 # -------------------------------------
615 # Automate configure check
616 # -------------------------------------
617 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
618 ( cd "${LyxSourceDir}" && sh autogen.sh )
620 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
621 dname=$(dirname "$file")
622 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
623 ( cd "${LyxSourceDir}" && sh autogen.sh )
628 # -------------------------------------
629 # Build LyX for different architectures
630 # -------------------------------------
632 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
633 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
634 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
637 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
638 HunSpellFramework=$(framework_name Hunspell)
639 HunSpellFramework=$(basename "${HunSpellFramework}")
640 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
641 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
642 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
644 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
645 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
647 for arch in ${ARCH_LIST} ; do
649 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
650 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
652 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
653 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
655 if [ "$configure_qt_frameworks" = "yes" ]; then
656 export QT_CORE_CFLAGS="-FQtCore"
657 export QT_CORE_LIBS="-framework QtCore"
658 export QT_FRONTEND_CFLAGS="-FQtGui"
659 export QT_FRONTEND_LIBS="-framework QtGui"
660 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
661 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
664 echo LDFLAGS="${LDFLAGS}"
666 echo CPPFLAGS="${CPPFLAGS}"
668 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"}
669 "${LyxSourceDir}/configure"\
670 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
671 ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"} \
672 ${LyXConfigureOptions}\
673 --enable-build-type=rel && \
674 make ${MAKEJOBS} && make install${strip}
675 for file in ${LYX_FILE_LIST} ; do
676 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
677 mv "${LYX_BUNDLE_PATH}/${file}"\
678 "${LYX_BUNDLE_PATH}/${file}-${arch}"
680 echo ERROR: Cannot build and install LyX for ${arch}.
687 content_directory() {
689 content=$(dirname "${target}")
690 content=$(dirname "${content}")
695 echo install_name_tool "$@"
696 install_name_tool "$@"
699 private_framework() {
700 fwdir=$(framework_name "$1")
703 condir=$(content_directory "${target}")
704 libnm=$(basename "${source}")
705 mkdir -p "${condir}/${fwdir}"
706 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
707 cp -p "${source}" "${condir}/${fwdir}"
708 installname -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
710 installname -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
714 source="${QtInstallDir}"
716 version="Versions/${QtFrameworkVersion}/"
717 condir=$(content_directory "${target}")
718 mkdir -p "${condir}/Resources"
719 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
722 Translations = translations
724 if [ ! -d "${condir}/PlugIns" ]; then
725 mkdir -p "${condir}/PlugIns"
726 find "${source}/plugins" -name \*.dylib -print | grep -v _debug.dylib | while read libname ; do
727 echo Copy plugin "${libname}"
728 dylib=$(basename "${libname}")
729 dirname=$(dirname "${libname}")
730 dirname=$(basename "${dirname}")
731 mkdir -p "${condir}/PlugIns/${dirname}"
732 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
735 for libnm in ${QtLibraries} ; do
736 fwdir=$(framework_name "$libnm")
737 dirname=$(dirname "${fwdir}")
738 mkdir -p "${condir}/${dirname}"
739 dirname=$(basename "${fwdir}")
740 test -d "${condir}/${fwdir}" || (
741 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
742 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
743 installname -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
744 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
745 if [ "${filename}" != "${target}" ]; then
746 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
747 # pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
749 *@rpath/*"${libnm}"*"("*version*")"*)
750 echo rpath based name for ${libnm} is ok.
752 *"${libnm}"*"("*version*")"*)
754 "${source}/lib/${dirname}/${version}${libnm}"\
755 "@executable_path/../${fwdir}/${version}${libnm}"\
764 "${source}/lib/${dirname}/${version}${libnm}"\
765 "@executable_path/../${fwdir}/${version}${libnm}"\
768 if [ ! -d "${condir}/translations" ]; then
769 mkdir -p "${condir}/translations"
771 echo Copy Qt translations to "${condir}/translations"
772 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
775 # -------------------------
776 # Create universal binaries
777 # -------------------------
778 convert_universal() {
780 for file in ${LYX_FILE_LIST} ; do
782 for arch in ${ARCH_LIST} ; do
783 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
784 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
787 if [ -n "${OBJ_LIST}" ]; then
788 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
790 if [ -f "${LibMagicInstallDir}/lib/${LibMagicLibrary}" -a "yes" = "${libmagic_deployment}" ]; then
791 private_framework LibMagic "${LibMagicInstallDir}/lib/${LibMagicLibrary}" "${LYX_BUNDLE_PATH}/${file}"
793 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
794 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
796 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
797 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
799 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
800 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
802 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
803 case "${reference}" in
804 *"${LyxBuildDir}"*"("*")")
805 echo ERROR: Bad reference to "${reference}" found!!
810 for arch in ${ARCH_LIST} ; do
811 rm -f ${BUNDLE_PATH}/*-${arch}
816 find "$@" -type f -print | while read file ; do
817 echo $(md5 -q "$file") "$file"
818 done | sort | while read hash file ; do
819 ppath=$(dirname "$pfile")
820 path=$(dirname "$file")
821 if [ "$phash" = "$hash" -a "$ppath" = "$path" ]; then
822 pname=$(basename "$pfile")
823 name=$(basename "$file")
824 cmp -s "$pfile" "$file" && (
826 cd "$path" && ln -s "$pname" "$name" && echo link for "$file" created
834 copy_dictionaries() {
835 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
836 ASpellResources="${LyxAppPrefix}/Contents/Resources"
837 # try to reuse macports dictionaries for now
838 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
839 mkdir -p "${ASpellResources}"
840 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
841 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
842 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
843 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
845 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
846 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
847 if [ -d "${DictionarySourceDir}" ]; then
848 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
849 deduplicate "${HunSpellResources}"/dicts
852 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
853 MyThesResources="${LyxAppPrefix}/Contents/Resources"
854 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
855 deduplicate "${MyThesResources}"/thes
859 set_bundle_display_options() {
862 Y_POSITION=$((Y_BOUNDS - 65))
863 Y_BOUNDS=$((Y_BOUNDS + 20))
864 LYX_X_POSITION=$((X_BOUNDS / 4))
865 LYX_Y_POSITION=$Y_POSITION
866 APP_X_POSITION=$((3 * X_BOUNDS / 4))
867 APP_Y_POSITION=$Y_POSITION
868 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
870 tell application "Finder"
871 set f to POSIX file ("${1}" as string) as alias
874 tell container window
875 set toolbar visible to false
876 set statusbar visible to false
877 set current view to icon view
879 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
882 set icon size of the icon view options of container window to 64
883 set arrangement of the icon view options of container window to not arranged
884 if ${WITH_DOCUMENTS} then
885 set position of item "Documents" to {$LYX_X_POSITION,0}
887 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
888 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
889 set background picture of the icon view options\
890 of container window to file "background.png" of folder "Pictures"
891 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
892 update without registering applications
904 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
905 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
906 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
908 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
910 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
911 # Unmount currently mounted disk image
912 mount | grep "${LyxBase}" && umount /Volumes/"${LyxBase}"
913 test -d /Volumes/"${LyxBase}" && rmdir /Volumes/"${LyxBase}"
915 # Mount the disk image
916 hdiutil attach "${DMGNAME}.sparseimage"
918 # Obtain device information
919 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
920 DEV=$(echo $DEVS | cut -f 1 -d ' ')
921 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
923 # copy in the application bundle
924 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
926 # copy in background image
927 mkdir -p "${VOLUME}/Pictures"
928 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
929 # symlink applications
930 ln -s /Applications/ "${VOLUME}"/Applications
931 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
932 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
933 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
934 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
936 # Unmount the disk image
937 hdiutil detach ${DEV}
939 # Convert the disk image to read-only
940 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
941 rm -f "${DMGNAME}.sparseimage"
944 # ------------------------------
945 # Building distribution packages
946 # ------------------------------
949 test -n "${LyxAppZip}" && (
950 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
954 for arch in ${ARCH_LIST} ; do
955 DMGARCH="${DMGARCH}-${arch}"
957 QtDmgArchSuffix=${QtMajorVersion}${DMGARCH}${QtAPI}.dmg
959 test -n "${DMGLocation}" && (
960 make_dmg "${DMGLocation}"
961 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
962 rm -f "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
963 echo move to "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
964 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
969 # ------------------------------
971 # ------------------------------
973 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then