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="${QtConfigureOptions} -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"
50 Qt4DmgSuffix=qt4${Qt4API}.dmg
52 # stupid special case...
53 case "${Qt4Version}:${Qt4API}" in
57 Qt4ConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -fast -no-strip"
58 Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-javascript-jit -no-pkg-config"
59 Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
60 Qt4DmgSuffix=qt5${Qt4API}.dmg
63 Qt4DmgSuffix=qt5${Qt4API}.dmg
66 Qt4ConfigureOptions="${Qt4ConfigureOptions} ${Qt4API}"
70 aspell_dictionaries="no"
71 hunspell_dictionaries="yes"
73 gettext_deployment="no"
74 aspell_deployment="yes"
75 hunspell_deployment="yes"
76 thesaurus_deployment="yes"
80 # auto detect Xcode location
81 if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
82 DEVELOPER_SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
83 XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
84 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
85 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.7.sdk" # Lion build is default
86 elif [ -d "/Developer/SDKs" ]; then
87 DEVELOPER_SDKS="/Developer/SDKs"
88 XCODE_DEVELOPER="/Developer"
89 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
90 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
93 # detection of script home
94 LyxSourceDir=$(dirname "$0")
95 if [ ! -d "${LyxSourceDir}" ]; then
96 echo Missing LyX source directory.
99 case "${LyxSourceDir}" in
101 LyxSourceDir=$(dirname "${LyxSourceDir}")
105 */development|development)
106 LyxSourceDir=$(dirname "${LyxSourceDir}")
107 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
110 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
115 echo "*" Build script for LyX on Mac OS X
117 echo Optional arguments:
118 echo " --aspell-deployment=yes|no ." default yes
119 echo " --with-qt4-frameworks=yes|no" default no
120 echo " --qt4-deployment=yes|no ...." default yes
121 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
122 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
123 echo " --with-arch=ARCH ..........." default ppc,i386
124 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
125 echo " --with-dmg-location=PATH ..." default \${build-path}
127 echo "All other arguments with -- are passed to configure"
128 echo "including the defaults: ${LyXConfigureOptions}"
129 if [ -x "${LyxSourceDir}/configure" ]; then
131 echo "*" Configure options of LyX
133 "${LyxSourceDir}/configure" --help
138 NCPU=$(sysctl -n hw.ncpu)
140 if [ $NCPU -gt 1 ]; then
144 while [ $# -gt 0 ]; do
146 --with-qt4-frameworks=*)
147 configure_qt4_frameworks=$(echo ${1}|cut -d= -f2)
148 if [ "$configure_qt4_frameworks" = "yes" ]; then
155 QTDIR=$(echo ${1}|cut -d= -f2)
158 --with-macosx-target=*)
159 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
163 SDKROOT=$(echo ${1}|cut -d= -f2)
166 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
172 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
180 --gettext-deployment=*)
181 gettext_deployment=$(echo ${1}|cut -d= -f2)
184 --aspell-deployment=*)
185 aspell_deployment=$(echo ${1}|cut -d= -f2)
186 aspell_dictionaries=$aspell_deployment
189 --hunspell-deployment=*)
190 hunspell_deployment=$(echo ${1}|cut -d= -f2)
191 hunspell_dictionaries=$hunspell_deployment
194 --thesaurus-deployment=*)
195 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
199 qt4_deployment=$(echo ${1}|cut -d= -f2)
203 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
204 ARCH_LIST="${ARCH_LIST} ${ARCH}"
207 --with-dmg-location=*)
208 DMGLocation=$(echo ${1}|cut -d= -f2)
212 LyxBuildDir=$(echo ${1}|cut -d= -f2)
219 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
220 aspell_deployment="no"
224 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
225 hunspell_deployment="no"
229 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
233 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
242 if [ "${configure_qt4_frameworks}" != "yes" ]; then
243 QtInstallDir=${QTDIR:-"/opt/qt4"}
246 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
251 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
252 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
254 GettextSourceDir=${GETTEXTDIR:-$(dirname "${LyxSourceDir}")/${GettextSource}}
255 GettextBuildDir="${LyxBuildDir}"/"${GettextSource}"
256 GettextInstallDir=${GettextInstallDir:-"${LyxBuildDir}"/utilities}
257 GettextInstallHdr="${GettextInstallDir}/include/libintl.h"
259 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
260 ASpellBuildDir="${ASpellSourceDir}"
261 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/utilities}
262 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
264 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
265 HunSpellBuildDir="${HunSpellSourceDir}"
266 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/utilities}
267 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
269 Qt4SourceDir=${QT4SOURCEDIR:-$(dirname "${LyxSourceDir}")/${Qt4SourceVersion}}
270 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4BuildSubDir:-"qt4-build"}}
272 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
273 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
274 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
276 if [ -z "${LyXVersion}" ]; then
277 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
279 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
282 LyxBase="${LyxName}-${LyXVersion}"
283 LyxApp="${LyxBase}.app"
284 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
285 LyxBuildDir="${LyxAppDir}.build"
286 LyxAppPrefix="${LyxAppDir}.app"
287 # if zip file is needed... remove the comment sign
288 #LyxAppZip="${LyxAppPrefix}.zip"
290 # ---------------------------------
291 # DON'T MODIFY ANYTHING BELOW HERE!
292 # ---------------------------------
294 # don't change order here...
295 case "${Qt4Version}" in
297 QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
298 QtFrameworkVersion="5"
301 QtLibraries="QtSvg QtXml QtPrintSupport QtMacExtras QtWidgets QtGui QtNetwork QtConcurrent QtCore"
302 QtFrameworkVersion="5"
305 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
306 QtFrameworkVersion="4"
313 # Check for existing SDKs
314 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
319 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
320 case "${MACOSX_DEPLOYMENT_TARGET}" in
322 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
325 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
330 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
331 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
334 echo Unknown or missing SDK for Mac OS X.
338 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
340 # pkg-config is not usable with this script
343 # These variables define the identifiers of the
344 # system (both Intel and PowerPC) to compile for.
345 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
346 # Only change these if necessary
348 HostSystem_i386="i686-apple-darwin8"
349 HostSystem_ppc="powerpc-apple-darwin8"
351 if [ "${configure_qt4_frameworks}" != "yes" -a -d "${Qt4SourceDir}" -a ! \( -d "${Qt4BuildDir}" -a -d "${QtInstallDir}" \) ]; then
352 echo Build Qt4 library ${Qt4SourceDir}
353 if [ "${QtInstallDir}" = "${Qt4BuildDir}" ]; then
354 echo Bad install directory for Qt.
355 echo Must be different from build directory "${Qt4BuildDir}".
359 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
360 for arch in ${ARCH_LIST} ; do
361 ARCHS="${ARCHS} -arch ${arch}"
363 echo configure options:
364 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
365 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
366 make ${MAKEJOBS} && make install
368 cd "${QtInstallDir}" && (
371 for libnm in ${QtLibraries} ; do
372 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
377 if [ -d "${GettextSourceDir}" -a ! -f "${GettextInstallHdr}" ]; then
378 # we have a private Gettext source tree at hand...
379 # so let's build and install it
380 if [ -z "${GettextVersion}" ]; then
381 GettextVersion=$(grep AC_INIT "${GettextSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
384 GettextName="Gettext"
385 GettextBase="${GettextName}-${GettextVersion}"
387 echo Build gettext library ${GettextBase}
388 echo configure options:
389 echo --prefix="${GettextInstallDir}" ${GettextConfigureOptions}
391 mkdir -p "${GettextBuildDir}" && cd "${GettextBuildDir}"
393 # ----------------------------------------
394 # Build Gettext for different architectures
395 # ----------------------------------------
396 FILE_LIST="${GettextLibrary}"
398 for arch in ${ARCH_LIST} ; do
399 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
400 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
401 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
402 "${GettextSourceDir}/configure"\
403 --prefix="${GettextInstallDir}"\
404 ${GettextConfigureOptions}
405 make && make install${strip}
406 for file in ${FILE_LIST} ; do
407 if [ -f "${GettextInstallDir}"/lib/${file} ]; then
408 mv "${GettextInstallDir}"/lib/${file}\
409 "${GettextInstallDir}"/lib/${file}-${arch}
411 echo Cannot build and install Gettext for ${arch}.
416 # -------------------------
417 # Create universal binaries
418 # -------------------------
419 for file in ${FILE_LIST} ; do
421 for arch in ${ARCH_LIST} ; do
422 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
425 cd "${GettextInstallDir}"
426 lipo -create ${OBJ_LIST} -o lib/${file}
432 for arch in ${ARCH_LIST} ; do
433 rm -f "${GettextInstallDir}"/lib/*-${arch}
437 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
438 # we have a private HunSpell source tree at hand...
439 # so let's build and install it
440 if [ -z "${HunSpellVersion}" ]; then
441 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
444 HunSpellName="Hunspell"
445 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
447 echo Build hunspell library ${HunSpellBase}
448 echo configure options:
449 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
451 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
453 # ----------------------------------------
454 # Build HunSpell for different architectures
455 # ----------------------------------------
456 FILE_LIST="${HunSpellLibrary}"
458 for arch in ${ARCH_LIST} ; do
460 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
461 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
462 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
463 "${HunSpellSourceDir}/configure"\
464 --prefix="${HunSpellInstallDir}"\
465 ${HunspellConfigureOptions}
466 make && make install${strip}
467 for file in ${FILE_LIST} ; do
468 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
469 mv "${HunSpellInstallDir}"/lib/${file}\
470 "${HunSpellInstallDir}"/lib/${file}-${arch}
472 echo Cannot build and install HunSpell for ${arch}.
477 # -------------------------
478 # Create universal binaries
479 # -------------------------
480 for file in ${FILE_LIST} ; do
482 for arch in ${ARCH_LIST} ; do
483 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
486 cd "${HunSpellInstallDir}"
487 lipo -create ${OBJ_LIST} -o lib/${file}
488 # check for the "missing link"...
489 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
495 for arch in ${ARCH_LIST} ; do
496 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
500 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
501 # we have a private ASpell source tree at hand...
502 # so let's build and install it
503 if [ -z "${ASpellVersion}" ]; then
504 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
508 ASpellBase="${ASpellName}-${ASpellVersion}"
510 echo Build aspell library ${ASpellBase}
511 echo configure options:
512 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
514 # ASpell builds inplace only :(
515 cd "${ASpellSourceDir}"
517 # ----------------------------------------
518 # Build ASpell for different architectures
519 # ----------------------------------------
520 FILE_LIST="${ASpellLibrary}"
522 for arch in ${ARCH_LIST} ; do
524 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
525 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
526 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
527 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
528 --prefix="${ASpellInstallDir}"\
529 ${AspellConfigureOptions}
530 make && make install${aspellstrip}
531 for file in ${FILE_LIST} ; do
532 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
533 mv "${ASpellInstallDir}"/lib/${file}\
534 "${ASpellInstallDir}"/lib/${file}-${arch}
536 echo Cannot build and install ASpell for ${arch}.
541 # -------------------------
542 # Create universal binaries
543 # -------------------------
544 for file in ${FILE_LIST} ; do
546 for arch in ${ARCH_LIST} ; do
547 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
550 cd "${ASpellInstallDir}"
551 lipo -create ${OBJ_LIST} -o lib/${file}
557 for arch in ${ARCH_LIST} ; do
558 rm -f "${ASpellInstallDir}"/lib/*-${arch}
564 echo "Frameworks/${1}.framework"
567 LYX_FILE_LIST="lyx lyxclient tex2lyx"
568 BUNDLE_PATH="Contents/MacOS"
569 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
572 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
573 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
575 # -------------------------------------
576 # Automate configure check
577 # -------------------------------------
578 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
579 ( cd "${LyxSourceDir}" && sh autogen.sh )
581 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
582 dname=$(dirname "$file")
583 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
584 ( cd "${LyxSourceDir}" && sh autogen.sh )
589 # -------------------------------------
590 # Build LyX for different architectures
591 # -------------------------------------
593 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
594 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
595 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
598 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
599 HunSpellFramework=$(framework_name Hunspell)
600 HunSpellFramework=$(basename "${HunSpellFramework}")
601 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
602 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
603 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
605 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
606 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
608 for arch in ${ARCH_LIST} ; do
610 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
611 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
613 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
614 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
615 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
617 if [ "$configure_qt4_frameworks" = "yes" ]; then
618 export QT4_CORE_CFLAGS="-FQtCore"
619 export QT4_CORE_LIBS="-framework QtCore"
620 export QT4_FRONTEND_CFLAGS="-FQtGui"
621 export QT4_FRONTEND_LIBS="-framework QtGui"
622 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
623 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
626 echo LDFLAGS="${LDFLAGS}"
628 echo CPPFLAGS="${CPPFLAGS}"
630 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"}
631 "${LyxSourceDir}/configure"\
632 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
633 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
634 ${LyXConfigureOptions}\
635 --enable-build-type=rel && \
636 make ${MAKEJOBS} && make install${strip}
637 for file in ${LYX_FILE_LIST} ; do
638 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
639 mv "${LYX_BUNDLE_PATH}/${file}"\
640 "${LYX_BUNDLE_PATH}/${file}-${arch}"
642 echo ERROR: Cannot build and install LyX for ${arch}.
649 content_directory() {
651 content=$(dirname "${target}")
652 content=$(dirname "${content}")
656 private_framework() {
657 fwdir=$(framework_name "$1")
660 condir=$(content_directory "${target}")
661 libnm=$(basename "${source}")
662 mkdir -p "${condir}/${fwdir}"
663 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
664 cp -p "${source}" "${condir}/${fwdir}"
665 echo Set library id in "${condir}/${fwdir}/${libnm}"
666 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
668 echo Correct library id reference to "${libnm}" in "${target}"
669 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
673 source="${QtInstallDir}"
675 version="Versions/${QtFrameworkVersion}/"
676 condir=$(content_directory "${target}")
677 mkdir -p "${condir}/Resources"
678 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
681 Translations = translations
683 if [ ! -d "${condir}/PlugIns" ]; then
684 mkdir -p "${condir}/PlugIns"
685 find "${source}/plugins" -name \*.dylib -print | grep -v _debug.dylib | while read libname ; do
686 echo Copy plugin "${libname}"
687 dylib=$(basename "${libname}")
688 dirname=$(dirname "${libname}")
689 dirname=$(basename "${dirname}")
690 mkdir -p "${condir}/PlugIns/${dirname}"
691 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
694 for libnm in ${QtLibraries} ; do
695 fwdir=$(framework_name "$libnm")
696 dirname=$(dirname "${fwdir}")
697 mkdir -p "${condir}/${dirname}"
698 dirname=$(basename "${fwdir}")
699 test -d "${condir}/${fwdir}" || (
700 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
701 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
702 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
703 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
704 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
705 if [ "${filename}" != "${target}" ]; then
706 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
707 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
709 *"${libnm}"*"("*version*")"*)
710 echo Correct library id reference to "${libnm}" in "${filename}"
711 install_name_tool -change\
712 "${source}/lib/${dirname}/${version}${libnm}"\
713 "@executable_path/../${fwdir}/${version}${libnm}"\
721 echo Correct library id reference to "${libnm}" in "${target}"
722 install_name_tool -change\
723 "${source}/lib/${dirname}/${version}${libnm}"\
724 "@executable_path/../${fwdir}/${version}${libnm}"\
727 if [ ! -d "${condir}/translations" ]; then
728 mkdir -p "${condir}/translations"
730 echo Copy Qt translations to "${condir}/translations"
731 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
734 # -------------------------
735 # Create universal binaries
736 # -------------------------
737 convert_universal() {
739 for file in ${LYX_FILE_LIST} ; do
741 for arch in ${ARCH_LIST} ; do
742 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
743 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
746 if [ -n "${OBJ_LIST}" ]; then
747 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
749 if [ -f "${GettextInstallDir}/lib/${GettextLibrary}" -a "yes" = "${gettext_deployment}" ]; then
750 private_framework Gettext "${GettextInstallDir}/lib/${GettextLibrary}" "${LYX_BUNDLE_PATH}/${file}"
752 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
753 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
755 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
756 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
758 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
759 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
761 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
762 case "${reference}" in
763 *"${LyxBuildDir}"*"("*")")
764 echo ERROR: Bad reference to "${reference}" found!!
769 for arch in ${ARCH_LIST} ; do
770 rm -f ${BUNDLE_PATH}/*-${arch}
774 copy_dictionaries() {
775 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
776 ASpellResources="${LyxAppPrefix}/Contents/Resources"
777 # try to reuse macports dictionaries for now
778 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
779 mkdir -p "${ASpellResources}"
780 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
781 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
782 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
783 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
785 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
786 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
787 if [ -d "${DictionarySourceDir}" ]; then
788 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
791 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
792 MyThesResources="${LyxAppPrefix}/Contents/Resources"
793 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
797 set_bundle_display_options() {
800 Y_POSITION=$((Y_BOUNDS - 65))
801 Y_BOUNDS=$((Y_BOUNDS + 20))
802 LYX_X_POSITION=$((X_BOUNDS / 4))
803 LYX_Y_POSITION=$Y_POSITION
804 APP_X_POSITION=$((3 * X_BOUNDS / 4))
805 APP_Y_POSITION=$Y_POSITION
806 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
808 tell application "Finder"
809 set f to POSIX file ("${1}" as string) as alias
812 tell container window
813 set toolbar visible to false
814 set statusbar visible to false
815 set current view to icon view
817 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
820 set icon size of the icon view options of container window to 64
821 set arrangement of the icon view options of container window to not arranged
822 if ${WITH_DOCUMENTS} then
823 set position of item "Documents" to {$LYX_X_POSITION,0}
825 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
826 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
827 set background picture of the icon view options\
828 of container window to file "background.png" of folder "Pictures"
829 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
830 update without registering applications
842 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
843 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
844 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
846 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
848 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
849 # Unmount currently mounted disk image
850 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
852 # Mount the disk image
853 hdiutil attach "${DMGNAME}.sparseimage"
855 # Obtain device information
856 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
857 DEV=$(echo $DEVS | cut -f 1 -d ' ')
858 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
860 # copy in the application bundle
861 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
863 # copy in background image
864 mkdir -p "${VOLUME}/Pictures"
865 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
866 # symlink applications
867 ln -s /Applications/ "${VOLUME}"/Applications
868 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
869 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
870 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
871 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
873 # Unmount the disk image
874 hdiutil detach ${DEV}
876 # Convert the disk image to read-only
877 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
878 rm -f "${DMGNAME}.sparseimage"
881 # ------------------------------
882 # Building distribution packages
883 # ------------------------------
886 test -n "${LyxAppZip}" && (
887 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
890 test -n "${DMGLocation}" && (
891 make_dmg "${DMGLocation}"
892 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
893 rm -f "${DMGLocation}/${DMGNAME}+${Qt4DmgSuffix}"
894 echo move to "${DMGLocation}/${DMGNAME}+${Qt4DmgSuffix}"
895 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+${Qt4DmgSuffix}"
900 # ------------------------------
902 # ------------------------------
904 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then