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"
51 # stupid special case...
52 case "${Qt4Version}:${Qt4API}" in
56 Qt4ConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -fast -no-strip"
57 Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-javascript-jit -no-pkg-config"
58 Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
61 Qt4ConfigureOptions="${Qt4ConfigureOptions} ${Qt4API}"
65 aspell_dictionaries="no"
66 hunspell_dictionaries="yes"
68 gettext_deployment="yes"
69 aspell_deployment="yes"
70 hunspell_deployment="yes"
71 thesaurus_deployment="yes"
75 # auto detect Xcode location
76 if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
77 DEVELOPER_SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
78 XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
79 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
80 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.7.sdk" # Lion build is default
81 elif [ -d "/Developer/SDKs" ]; then
82 DEVELOPER_SDKS="/Developer/SDKs"
83 XCODE_DEVELOPER="/Developer"
84 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
85 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
88 # detection of script home
89 LyxSourceDir=$(dirname "$0")
90 if [ ! -d "${LyxSourceDir}" ]; then
91 echo Missing LyX source directory.
94 case "${LyxSourceDir}" in
96 LyxSourceDir=$(dirname "${LyxSourceDir}")
100 */development|development)
101 LyxSourceDir=$(dirname "${LyxSourceDir}")
102 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
105 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
110 echo "*" Build script for LyX on Mac OS X
112 echo Optional arguments:
113 echo " --aspell-deployment=yes|no ." default yes
114 echo " --with-qt4-frameworks=yes|no" default no
115 echo " --qt4-deployment=yes|no ...." default yes
116 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
117 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
118 echo " --with-arch=ARCH ..........." default ppc,i386
119 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
120 echo " --with-dmg-location=PATH ..." default \${build-path}
122 echo "All other arguments with -- are passed to configure"
123 echo "including the defaults: ${LyXConfigureOptions}"
124 if [ -x "${LyxSourceDir}/configure" ]; then
126 echo "*" Configure options of LyX
128 "${LyxSourceDir}/configure" --help
133 NCPU=$(sysctl -n hw.ncpu)
135 if [ $NCPU -gt 1 ]; then
139 while [ $# -gt 0 ]; do
141 --with-qt4-frameworks=*)
142 configure_qt4_frameworks=$(echo ${1}|cut -d= -f2)
143 if [ "$configure_qt4_frameworks" = "yes" ]; then
150 QTDIR=$(echo ${1}|cut -d= -f2)
153 --with-macosx-target=*)
154 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
158 SDKROOT=$(echo ${1}|cut -d= -f2)
161 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
167 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
175 --gettext-deployment=*)
176 gettext_deployment=$(echo ${1}|cut -d= -f2)
179 --aspell-deployment=*)
180 aspell_deployment=$(echo ${1}|cut -d= -f2)
181 aspell_dictionaries=$aspell_deployment
184 --hunspell-deployment=*)
185 hunspell_deployment=$(echo ${1}|cut -d= -f2)
186 hunspell_dictionaries=$hunspell_deployment
189 --thesaurus-deployment=*)
190 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
194 qt4_deployment=$(echo ${1}|cut -d= -f2)
198 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
199 ARCH_LIST="${ARCH_LIST} ${ARCH}"
202 --with-dmg-location=*)
203 DMGLocation=$(echo ${1}|cut -d= -f2)
207 LyxBuildDir=$(echo ${1}|cut -d= -f2)
214 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
215 aspell_deployment="no"
219 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
220 hunspell_deployment="no"
224 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
228 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
237 if [ "${configure_qt4_frameworks}" != "yes" ]; then
238 QtInstallDir=${QTDIR:-"/opt/qt4"}
241 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
246 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
247 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
249 GettextSourceDir=${GETTEXTDIR:-$(dirname "${LyxSourceDir}")/${GettextSource}}
250 GettextBuildDir="${LyxBuildDir}"/"${GettextSource}"
251 GettextInstallDir=${GettextInstallDir:-"${LyxBuildDir}"/utilities}
252 GettextInstallHdr="${GettextInstallDir}/include/libintl.h"
254 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
255 ASpellBuildDir="${ASpellSourceDir}"
256 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/utilities}
257 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
259 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
260 HunSpellBuildDir="${HunSpellSourceDir}"
261 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/utilities}
262 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
264 Qt4SourceDir=${QT4SOURCEDIR:-$(dirname "${LyxSourceDir}")/${Qt4SourceVersion}}
265 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4BuildSubDir:-"qt4-build"}}
267 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
268 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
269 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
271 if [ -z "${LyXVersion}" ]; then
272 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
274 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
277 LyxBase="${LyxName}-${LyXVersion}"
278 LyxApp="${LyxBase}.app"
279 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
280 LyxBuildDir="${LyxAppDir}.build"
281 LyxAppPrefix="${LyxAppDir}.app"
282 # if zip file is needed... remove the comment sign
283 #LyxAppZip="${LyxAppPrefix}.zip"
285 # ---------------------------------
286 # DON'T MODIFY ANYTHING BELOW HERE!
287 # ---------------------------------
289 # don't change order here...
290 case "${Qt4Version}" in
292 QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
293 QtFrameworkVersion="5"
296 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
297 QtFrameworkVersion="4"
304 # Check for existing SDKs
305 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
310 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
311 case "${MACOSX_DEPLOYMENT_TARGET}" in
313 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
316 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
321 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
322 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
325 echo Unknown or missing SDK for Mac OS X.
329 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
331 # These variables define the identifiers of the
332 # system (both Intel and PowerPC) to compile for.
333 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
334 # Only change these if necessary
336 HostSystem_i386="i686-apple-darwin8"
337 HostSystem_ppc="powerpc-apple-darwin8"
339 if [ "${configure_qt4_frameworks}" != "yes" -a -d "${Qt4SourceDir}" -a ! \( -d "${Qt4BuildDir}" -a -d "${QtInstallDir}" \) ]; then
340 echo Build Qt4 library ${Qt4SourceDir}
341 if [ "${QtInstallDir}" = "${Qt4BuildDir}" ]; then
342 echo Bad install directory for Qt.
343 echo Must be different from build directory "${Qt4BuildDir}".
347 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
348 for arch in ${ARCH_LIST} ; do
349 ARCHS="${ARCHS} -arch ${arch}"
351 echo configure options:
352 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
353 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
354 make ${MAKEJOBS} && make install
356 cd "${QtInstallDir}" && (
359 for libnm in ${QtLibraries} ; do
360 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
365 if [ -d "${GettextSourceDir}" -a ! -f "${GettextInstallHdr}" ]; then
366 # we have a private Gettext source tree at hand...
367 # so let's build and install it
368 if [ -z "${GettextVersion}" ]; then
369 GettextVersion=$(grep AC_INIT "${GettextSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
372 GettextName="Gettext"
373 GettextBase="${GettextName}-${GettextVersion}"
375 echo Build gettext library ${GettextBase}
376 echo configure options:
377 echo --prefix="${GettextInstallDir}" ${GettextConfigureOptions}
379 mkdir -p "${GettextBuildDir}" && cd "${GettextBuildDir}"
381 # ----------------------------------------
382 # Build Gettext for different architectures
383 # ----------------------------------------
384 FILE_LIST="${GettextLibrary}"
386 for arch in ${ARCH_LIST} ; do
387 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
388 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
389 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
390 "${GettextSourceDir}/configure"\
391 --prefix="${GettextInstallDir}"\
392 ${GettextConfigureOptions}
393 make && make install${strip}
394 for file in ${FILE_LIST} ; do
395 if [ -f "${GettextInstallDir}"/lib/${file} ]; then
396 mv "${GettextInstallDir}"/lib/${file}\
397 "${GettextInstallDir}"/lib/${file}-${arch}
399 echo Cannot build and install Gettext for ${arch}.
404 # -------------------------
405 # Create universal binaries
406 # -------------------------
407 for file in ${FILE_LIST} ; do
409 for arch in ${ARCH_LIST} ; do
410 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
413 cd "${GettextInstallDir}"
414 lipo -create ${OBJ_LIST} -o lib/${file}
420 for arch in ${ARCH_LIST} ; do
421 rm -f "${GettextInstallDir}"/lib/*-${arch}
425 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
426 # we have a private HunSpell source tree at hand...
427 # so let's build and install it
428 if [ -z "${HunSpellVersion}" ]; then
429 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
432 HunSpellName="Hunspell"
433 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
435 echo Build hunspell library ${HunSpellBase}
436 echo configure options:
437 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
439 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
441 # ----------------------------------------
442 # Build HunSpell for different architectures
443 # ----------------------------------------
444 FILE_LIST="${HunSpellLibrary}"
446 for arch in ${ARCH_LIST} ; do
448 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
449 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
450 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
451 "${HunSpellSourceDir}/configure"\
452 --prefix="${HunSpellInstallDir}"\
453 ${HunspellConfigureOptions}
454 make && make install${strip}
455 for file in ${FILE_LIST} ; do
456 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
457 mv "${HunSpellInstallDir}"/lib/${file}\
458 "${HunSpellInstallDir}"/lib/${file}-${arch}
460 echo Cannot build and install HunSpell for ${arch}.
465 # -------------------------
466 # Create universal binaries
467 # -------------------------
468 for file in ${FILE_LIST} ; do
470 for arch in ${ARCH_LIST} ; do
471 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
474 cd "${HunSpellInstallDir}"
475 lipo -create ${OBJ_LIST} -o lib/${file}
476 # check for the "missing link"...
477 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
483 for arch in ${ARCH_LIST} ; do
484 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
488 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
489 # we have a private ASpell source tree at hand...
490 # so let's build and install it
491 if [ -z "${ASpellVersion}" ]; then
492 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
496 ASpellBase="${ASpellName}-${ASpellVersion}"
498 echo Build aspell library ${ASpellBase}
499 echo configure options:
500 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
502 # ASpell builds inplace only :(
503 cd "${ASpellSourceDir}"
505 # ----------------------------------------
506 # Build ASpell for different architectures
507 # ----------------------------------------
508 FILE_LIST="${ASpellLibrary}"
510 for arch in ${ARCH_LIST} ; do
512 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
513 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
514 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
515 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
516 --prefix="${ASpellInstallDir}"\
517 ${AspellConfigureOptions}
518 make && make install${aspellstrip}
519 for file in ${FILE_LIST} ; do
520 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
521 mv "${ASpellInstallDir}"/lib/${file}\
522 "${ASpellInstallDir}"/lib/${file}-${arch}
524 echo Cannot build and install ASpell for ${arch}.
529 # -------------------------
530 # Create universal binaries
531 # -------------------------
532 for file in ${FILE_LIST} ; do
534 for arch in ${ARCH_LIST} ; do
535 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
538 cd "${ASpellInstallDir}"
539 lipo -create ${OBJ_LIST} -o lib/${file}
545 for arch in ${ARCH_LIST} ; do
546 rm -f "${ASpellInstallDir}"/lib/*-${arch}
552 echo "Frameworks/${1}.framework"
555 LYX_FILE_LIST="lyx lyxclient tex2lyx"
556 BUNDLE_PATH="Contents/MacOS"
557 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
560 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
561 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
563 # -------------------------------------
564 # Automate configure check
565 # -------------------------------------
566 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
567 ( cd "${LyxSourceDir}" && sh autogen.sh )
569 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
570 dname=$(dirname "$file")
571 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
572 ( cd "${LyxSourceDir}" && sh autogen.sh )
577 # -------------------------------------
578 # Build LyX for different architectures
579 # -------------------------------------
581 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
582 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
583 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
586 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
587 HunSpellFramework=$(framework_name Hunspell)
588 HunSpellFramework=$(basename "${HunSpellFramework}")
589 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
590 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
591 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
593 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
594 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
596 for arch in ${ARCH_LIST} ; do
598 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
599 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
601 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
602 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
603 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
605 if [ "$configure_qt4_frameworks" = "yes" ]; then
606 export QT4_CORE_CFLAGS="-FQtCore"
607 export QT4_CORE_LIBS="-framework QtCore"
608 export QT4_FRONTEND_CFLAGS="-FQtGui"
609 export QT4_FRONTEND_LIBS="-framework QtGui"
611 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
612 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
615 echo LDFLAGS="${LDFLAGS}"
617 echo CPPFLAGS="${CPPFLAGS}"
619 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"}
620 "${LyxSourceDir}/configure"\
621 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
622 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
623 ${LyXConfigureOptions}\
624 --enable-build-type=rel && \
625 make ${MAKEJOBS} && make install${strip}
626 for file in ${LYX_FILE_LIST} ; do
627 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
628 mv "${LYX_BUNDLE_PATH}/${file}"\
629 "${LYX_BUNDLE_PATH}/${file}-${arch}"
631 echo ERROR: Cannot build and install LyX for ${arch}.
638 content_directory() {
640 content=$(dirname "${target}")
641 content=$(dirname "${content}")
645 private_framework() {
646 fwdir=$(framework_name "$1")
649 condir=$(content_directory "${target}")
650 libnm=$(basename "${source}")
651 mkdir -p "${condir}/${fwdir}"
652 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
653 cp -p "${source}" "${condir}/${fwdir}"
654 echo Set library id in "${condir}/${fwdir}/${libnm}"
655 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
657 echo Correct library id reference to "${libnm}" in "${target}"
658 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
662 source="${QtInstallDir}"
664 version="Versions/${QtFrameworkVersion}/"
665 condir=$(content_directory "${target}")
666 mkdir -p "${condir}/Resources"
667 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
670 Translations = translations
672 if [ ! -d "${condir}/PlugIns" ]; then
673 mkdir -p "${condir}/PlugIns"
674 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
675 echo Copy plugin "${libname}"
676 dylib=$(basename "${libname}")
677 dirname=$(dirname "${libname}")
678 dirname=$(basename "${dirname}")
679 mkdir -p "${condir}/PlugIns/${dirname}"
680 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
683 for libnm in ${QtLibraries} ; do
684 fwdir=$(framework_name "$libnm")
685 dirname=$(dirname "${fwdir}")
686 mkdir -p "${condir}/${dirname}"
687 dirname=$(basename "${fwdir}")
688 test -d "${condir}/${fwdir}" || (
689 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
690 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
691 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
692 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
693 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
694 if [ "${filename}" != "${target}" ]; then
695 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
696 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
698 *"${libnm}"*"("*version*")"*)
699 echo Correct library id reference to "${libnm}" in "${filename}"
700 install_name_tool -change\
701 "${source}/lib/${dirname}/${version}${libnm}"\
702 "@executable_path/../${fwdir}/${version}${libnm}"\
710 echo Correct library id reference to "${libnm}" in "${target}"
711 install_name_tool -change\
712 "${source}/lib/${dirname}/${version}${libnm}"\
713 "@executable_path/../${fwdir}/${version}${libnm}"\
716 if [ ! -d "${condir}/translations" ]; then
717 mkdir -p "${condir}/translations"
719 echo Copy Qt translations to "${condir}/translations"
720 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
723 # -------------------------
724 # Create universal binaries
725 # -------------------------
726 convert_universal() {
728 for file in ${LYX_FILE_LIST} ; do
730 for arch in ${ARCH_LIST} ; do
731 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
732 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
735 if [ -n "${OBJ_LIST}" ]; then
736 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
738 if [ -f "${GettextInstallDir}/lib/${GettextLibrary}" -a "yes" = "${gettext_deployment}" ]; then
739 private_framework Gettext "${GettextInstallDir}/lib/${GettextLibrary}" "${LYX_BUNDLE_PATH}/${file}"
741 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
742 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
744 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
745 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
747 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
748 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
750 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
751 case "${reference}" in
752 *"${LyxBuildDir}"*"("*")")
753 echo ERROR: Bad reference to "${reference}" found!!
758 for arch in ${ARCH_LIST} ; do
759 rm -f ${BUNDLE_PATH}/*-${arch}
763 copy_dictionaries() {
764 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
765 ASpellResources="${LyxAppPrefix}/Contents/Resources"
766 # try to reuse macports dictionaries for now
767 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
768 mkdir -p "${ASpellResources}"
769 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
770 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
771 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
772 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
774 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
775 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
776 if [ -d "${DictionarySourceDir}" ]; then
777 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
780 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
781 MyThesResources="${LyxAppPrefix}/Contents/Resources"
782 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
786 set_bundle_display_options() {
789 Y_POSITION=$((Y_BOUNDS - 65))
790 Y_BOUNDS=$((Y_BOUNDS + 20))
791 LYX_X_POSITION=$((X_BOUNDS / 4))
792 LYX_Y_POSITION=$Y_POSITION
793 APP_X_POSITION=$((3 * X_BOUNDS / 4))
794 APP_Y_POSITION=$Y_POSITION
795 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
797 tell application "Finder"
798 set f to POSIX file ("${1}" as string) as alias
801 tell container window
802 set toolbar visible to false
803 set statusbar visible to false
804 set current view to icon view
806 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
809 set icon size of the icon view options of container window to 64
810 set arrangement of the icon view options of container window to not arranged
811 if ${WITH_DOCUMENTS} then
812 set position of item "Documents" to {$LYX_X_POSITION,0}
814 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
815 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
816 set background picture of the icon view options\
817 of container window to file "background.png" of folder "Pictures"
818 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
819 update without registering applications
831 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
832 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
833 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
835 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
837 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
838 # Unmount currently mounted disk image
839 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
841 # Mount the disk image
842 hdiutil attach "${DMGNAME}.sparseimage"
844 # Obtain device information
845 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
846 DEV=$(echo $DEVS | cut -f 1 -d ' ')
847 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
849 # copy in the application bundle
850 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
852 # copy in background image
853 mkdir -p "${VOLUME}/Pictures"
854 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
855 # symlink applications
856 ln -s /Applications/ "${VOLUME}"/Applications
857 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
858 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
859 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
860 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
862 # Unmount the disk image
863 hdiutil detach ${DEV}
865 # Convert the disk image to read-only
866 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
867 rm -f "${DMGNAME}.sparseimage"
870 # ------------------------------
871 # Building distribution packages
872 # ------------------------------
875 test -n "${LyxAppZip}" && (
876 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
879 test -n "${DMGLocation}" && (
880 make_dmg "${DMGLocation}"
881 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
882 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
883 echo move to "${DMGLocation}/${DMGNAME}+qt4${Qt4API}.dmg"
884 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4${Qt4API}.dmg"
889 # ------------------------------
891 # ------------------------------
893 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then