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"
51 QtConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -fast -no-exceptions"
52 QtConfigureOptions="${QtConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
53 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
56 # stupid special case...
57 case "${QtVersion}:${QtAPI}" in
61 QtConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -fast -no-strip"
62 QtConfigureOptions="${QtConfigureOptions} -no-javascript-jit -no-pkg-config"
63 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
70 QtConfigureOptions="${QtConfigureOptions} ${QtAPI}"
74 aspell_dictionaries="no"
75 hunspell_dictionaries="yes"
77 libmagic_deployment="yes"
78 aspell_deployment="yes"
79 hunspell_deployment="yes"
80 thesaurus_deployment="yes"
84 # auto detect Xcode location
85 if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
86 DEVELOPER_SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
87 XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
88 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
89 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.7.sdk" # Lion build is default
90 elif [ -d "/Developer/SDKs" ]; then
91 DEVELOPER_SDKS="/Developer/SDKs"
92 XCODE_DEVELOPER="/Developer"
93 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
94 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
97 # detection of script home
98 LyxSourceDir=$(dirname "$0")
99 if [ ! -d "${LyxSourceDir}" ]; then
100 echo Missing LyX source directory.
103 case "${LyxSourceDir}" in
105 LyxSourceDir=$(dirname "${LyxSourceDir}")
109 */development|development)
110 LyxSourceDir=$(dirname "${LyxSourceDir}")
111 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
114 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
119 echo "*" Build script for LyX on Mac OS X
121 echo Optional arguments:
122 echo " --aspell-deployment=yes|no ." default yes
123 echo " --with-qt-frameworks=yes|no." default no
124 echo " --qt-deployment=yes|no ....." default yes
125 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
126 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
127 echo " --with-arch=ARCH ..........." default ppc,i386
128 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
129 echo " --with-dmg-location=PATH ..." default \${build-path}
130 echo " --with-binary-strip=yes ...." default no
132 echo "All other arguments with -- are passed to configure"
133 echo "including the defaults: ${LyXConfigureOptions}"
138 if [ -x "${LyxSourceDir}/configure" ]; then
140 echo "*" Configure options of LyX
142 "${LyxSourceDir}/configure" --help
148 NCPU=$(sysctl -n hw.ncpu)
150 if [ $NCPU -gt 1 ]; then
154 while [ $# -gt 0 ]; do
156 --with-qt-frameworks=*)
157 configure_qt_frameworks=$(echo ${1}|cut -d= -f2)
158 if [ "$configure_qt_frameworks" = "yes" ]; then
165 QTDIR=$(echo ${1}|cut -d= -f2)
168 --with-macosx-target=*)
169 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
173 SDKROOT=$(echo ${1}|cut -d= -f2)
176 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
182 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
190 --libmagic-deployment=*)
191 libmagic_deployment=$(echo ${1}|cut -d= -f2)
194 --aspell-deployment=*)
195 aspell_deployment=$(echo ${1}|cut -d= -f2)
196 aspell_dictionaries=$aspell_deployment
199 --hunspell-deployment=*)
200 hunspell_deployment=$(echo ${1}|cut -d= -f2)
201 hunspell_dictionaries=$hunspell_deployment
204 --thesaurus-deployment=*)
205 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
209 qt_deployment=$(echo ${1}|cut -d= -f2)
213 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
214 ARCH_LIST="${ARCH_LIST} ${ARCH}"
217 --with-dmg-location=*)
218 DMGLocation=$(echo ${1}|cut -d= -f2)
221 --with-binary-strip=yes)
226 LyxBuildDir=$(echo ${1}|cut -d= -f2)
230 LyXUtilitiesDir=$(echo ${1}|cut -d= -f2)
237 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
238 aspell_deployment="no"
242 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
243 hunspell_deployment="no"
247 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
251 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
260 if [ "${configure_qt_frameworks}" != "yes" ]; then
261 QtInstallDir=${QTDIR:-"/opt/qt4"}
264 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
268 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
269 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
271 LibMagicSourceDir=${LIBMAGICDIR:-$(dirname "${LyxSourceDir}")/${LibMagicSource}}
272 LibMagicBuildDir="${LyxBuildDir}"/"${LibMagicSource}"
273 LibMagicInstallDir=${LibMagicInstallDir:-"${LyXUtilitiesDir}"}
274 LibMagicInstallHdr="${LibMagicInstallDir}/include/magic.h"
276 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
277 ASpellBuildDir="${ASpellSourceDir}"
278 ASpellInstallDir=${ASpellInstallDir:-"${LyXUtilitiesDir}"}
279 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
281 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
282 HunSpellBuildDir="${HunSpellSourceDir}"
283 HunSpellInstallDir=${HunSpellInstallDir:-"${LyXUtilitiesDir}"}
284 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
286 QtSourceDir=${QTSOURCEDIR:-$(dirname "${LyxSourceDir}")/${QtSourceVersion}}
287 QtBuildDir=${QtBuildDir:-"${LyxBuildDir}"/${QtBuildSubDir:-"qt-build"}}
289 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
290 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
291 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
293 if [ -z "${LyXVersion}" ]; then
294 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
296 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
299 LyxBase="${LyxName}-${LyXVersion}"
300 LyxApp="${LyxBase}.app"
301 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
302 LyxBuildDir="${LyxAppDir}.build"
303 LyxAppPrefix="${LyxAppDir}.app"
304 # if zip file is needed... remove the comment sign
305 #LyxAppZip="${LyxAppPrefix}.zip"
307 # ---------------------------------
308 # DON'T MODIFY ANYTHING BELOW HERE!
309 # ---------------------------------
311 # don't change order here...
312 case "${QtVersion}" in
314 QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
315 QtFrameworkVersion="5"
318 QtLibraries="QtSvg QtXml QtPrintSupport QtMacExtras QtWidgets QtGui QtNetwork QtConcurrent QtCore"
319 QtFrameworkVersion="5"
322 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
323 QtFrameworkVersion="4"
330 # Check for existing SDKs
331 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
336 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
337 case "${MACOSX_DEPLOYMENT_TARGET}" in
339 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
342 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
347 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
348 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
351 echo Unknown or missing SDK for Mac OS X.
355 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
357 # pkg-config is not usable with this script
360 # These variables define the identifiers of the
361 # system (both Intel and PowerPC) to compile for.
362 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
363 # Only change these if necessary
365 HostSystem_i386="i686-apple-darwin8"
366 HostSystem_ppc="powerpc-apple-darwin8"
368 if [ "${configure_qt_frameworks}" != "yes" -a -d "${QtSourceDir}" -a ! \( -d "${QtBuildDir}" -a -d "${QtInstallDir}" \) ]; then
369 echo Build Qt library ${QtSourceDir}
370 if [ "${QtInstallDir}" = "${QtBuildDir}" ]; then
371 echo Bad install directory for Qt.
372 echo Must be different from build directory "${QtBuildDir}".
376 mkdir -p "${QtBuildDir}" && cd "${QtBuildDir}"
377 for arch in ${ARCH_LIST} ; do
378 ARCHS="${ARCHS} -arch ${arch}"
380 echo configure options:
381 echo ${QtConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
382 echo yes | "${QtSourceDir}"/configure ${QtConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
383 make ${MAKEJOBS} && make install
385 cd "${QtInstallDir}" && (
388 for libnm in ${QtLibraries} ; do
389 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
394 if [ -d "${LibMagicSourceDir}" -a ! -f "${LibMagicInstallHdr}" ]; then
395 # we have a private libmagic (file(1)) source tree at hand...
396 # so let's build and install it
397 if [ -z "${LibMagicVersion}" ]; then
398 LibMagicVersion=$(grep AC_INIT "${LibMagicSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
401 LibMagicName="LibMagic"
402 LibMagicBase="${LibMagicName}-${LibMagicVersion}"
404 echo Build libmagic library ${LibMagicBase}
405 echo configure options:
406 echo --prefix="${LibMagicInstallDir}" ${LibMagicConfigureOptions}
408 mkdir -p "${LibMagicBuildDir}" && cd "${LibMagicBuildDir}"
410 # ----------------------------------------
411 # Build LibMagic for different architectures
412 # ----------------------------------------
413 FILE_LIST="${LibMagicLibrary}"
415 for arch in ${ARCH_LIST} ; do
416 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
417 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
418 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
419 "${LibMagicSourceDir}/configure"\
420 --prefix="${LibMagicInstallDir}"\
421 ${LibMagicConfigureOptions}
422 make && make install${strip}
423 for file in ${FILE_LIST} ; do
424 if [ -f "${LibMagicInstallDir}"/lib/${file} ]; then
425 mv "${LibMagicInstallDir}"/lib/${file}\
426 "${LibMagicInstallDir}"/lib/${file}-${arch}
428 echo Cannot build and install LibMagic for ${arch}.
433 # -------------------------
434 # Create universal binaries
435 # -------------------------
436 for file in ${FILE_LIST} ; do
438 for arch in ${ARCH_LIST} ; do
439 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
442 cd "${LibMagicInstallDir}"
443 lipo -create ${OBJ_LIST} -o lib/${file}
449 for arch in ${ARCH_LIST} ; do
450 rm -f "${LibMagicInstallDir}"/lib/*-${arch}
454 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
455 # we have a private HunSpell source tree at hand...
456 # so let's build and install it
457 if [ -z "${HunSpellVersion}" ]; then
458 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
461 HunSpellName="Hunspell"
462 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
464 echo Build hunspell library ${HunSpellBase}
465 echo configure options:
466 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
468 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
470 # ----------------------------------------
471 # Build HunSpell for different architectures
472 # ----------------------------------------
473 FILE_LIST="${HunSpellLibrary}"
475 for arch in ${ARCH_LIST} ; do
477 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
478 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
479 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
480 "${HunSpellSourceDir}/configure"\
481 --prefix="${HunSpellInstallDir}"\
482 ${HunspellConfigureOptions}
483 make && make install${strip}
484 for file in ${FILE_LIST} ; do
485 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
486 mv "${HunSpellInstallDir}"/lib/${file}\
487 "${HunSpellInstallDir}"/lib/${file}-${arch}
489 echo Cannot build and install HunSpell for ${arch}.
494 # -------------------------
495 # Create universal binaries
496 # -------------------------
497 for file in ${FILE_LIST} ; do
499 for arch in ${ARCH_LIST} ; do
500 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
503 cd "${HunSpellInstallDir}"
504 lipo -create ${OBJ_LIST} -o lib/${file}
505 # check for the "missing link"...
506 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
512 for arch in ${ARCH_LIST} ; do
513 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
517 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
518 # we have a private ASpell source tree at hand...
519 # so let's build and install it
520 if [ -z "${ASpellVersion}" ]; then
521 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
525 ASpellBase="${ASpellName}-${ASpellVersion}"
527 echo Build aspell library ${ASpellBase}
528 echo configure options:
529 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
531 # ASpell builds inplace only :(
532 cd "${ASpellSourceDir}"
534 # ----------------------------------------
535 # Build ASpell for different architectures
536 # ----------------------------------------
537 FILE_LIST="${ASpellLibrary}"
539 for arch in ${ARCH_LIST} ; do
541 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
542 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
543 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
544 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
545 --prefix="${ASpellInstallDir}"\
546 ${AspellConfigureOptions}
547 make && make install${aspellstrip}
548 for file in ${FILE_LIST} ; do
549 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
550 mv "${ASpellInstallDir}"/lib/${file}\
551 "${ASpellInstallDir}"/lib/${file}-${arch}
553 echo Cannot build and install ASpell for ${arch}.
558 # -------------------------
559 # Create universal binaries
560 # -------------------------
561 for file in ${FILE_LIST} ; do
563 for arch in ${ARCH_LIST} ; do
564 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
567 cd "${ASpellInstallDir}"
568 lipo -create ${OBJ_LIST} -o lib/${file}
574 for arch in ${ARCH_LIST} ; do
575 rm -f "${ASpellInstallDir}"/lib/*-${arch}
581 echo "Frameworks/${1}.framework"
584 LYX_FILE_LIST="lyx lyxclient tex2lyx"
585 BUNDLE_PATH="Contents/MacOS"
586 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
589 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
590 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
592 # -------------------------------------
593 # Automate configure check
594 # -------------------------------------
595 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
596 ( cd "${LyxSourceDir}" && sh autogen.sh )
598 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
599 dname=$(dirname "$file")
600 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
601 ( cd "${LyxSourceDir}" && sh autogen.sh )
606 # -------------------------------------
607 # Build LyX for different architectures
608 # -------------------------------------
610 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
611 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
612 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
615 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
616 HunSpellFramework=$(framework_name Hunspell)
617 HunSpellFramework=$(basename "${HunSpellFramework}")
618 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
619 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
620 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
622 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
623 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
625 for arch in ${ARCH_LIST} ; do
627 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
628 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
630 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
631 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
632 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
634 if [ "$configure_qt_frameworks" = "yes" ]; then
635 export QT_CORE_CFLAGS="-FQtCore"
636 export QT_CORE_LIBS="-framework QtCore"
637 export QT_FRONTEND_CFLAGS="-FQtGui"
638 export QT_FRONTEND_LIBS="-framework QtGui"
639 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
640 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
643 echo LDFLAGS="${LDFLAGS}"
645 echo CPPFLAGS="${CPPFLAGS}"
647 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"}
648 "${LyxSourceDir}/configure"\
649 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
650 ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"} \
651 ${LyXConfigureOptions}\
652 --enable-build-type=rel && \
653 make ${MAKEJOBS} && make install${strip}
654 for file in ${LYX_FILE_LIST} ; do
655 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
656 mv "${LYX_BUNDLE_PATH}/${file}"\
657 "${LYX_BUNDLE_PATH}/${file}-${arch}"
659 echo ERROR: Cannot build and install LyX for ${arch}.
666 content_directory() {
668 content=$(dirname "${target}")
669 content=$(dirname "${content}")
673 private_framework() {
674 fwdir=$(framework_name "$1")
677 condir=$(content_directory "${target}")
678 libnm=$(basename "${source}")
679 mkdir -p "${condir}/${fwdir}"
680 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
681 cp -p "${source}" "${condir}/${fwdir}"
682 echo Set library id in "${condir}/${fwdir}/${libnm}"
683 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
685 echo Correct library id reference to "${libnm}" in "${target}"
686 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
690 source="${QtInstallDir}"
692 version="Versions/${QtFrameworkVersion}/"
693 condir=$(content_directory "${target}")
694 mkdir -p "${condir}/Resources"
695 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
698 Translations = translations
700 if [ ! -d "${condir}/PlugIns" ]; then
701 mkdir -p "${condir}/PlugIns"
702 find "${source}/plugins" -name \*.dylib -print | grep -v _debug.dylib | while read libname ; do
703 echo Copy plugin "${libname}"
704 dylib=$(basename "${libname}")
705 dirname=$(dirname "${libname}")
706 dirname=$(basename "${dirname}")
707 mkdir -p "${condir}/PlugIns/${dirname}"
708 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
711 for libnm in ${QtLibraries} ; do
712 fwdir=$(framework_name "$libnm")
713 dirname=$(dirname "${fwdir}")
714 mkdir -p "${condir}/${dirname}"
715 dirname=$(basename "${fwdir}")
716 test -d "${condir}/${fwdir}" || (
717 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
718 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
719 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
720 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
721 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
722 if [ "${filename}" != "${target}" ]; then
723 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
724 # pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
726 *"${libnm}"*"("*version*")"*)
727 echo Correct library id reference to "${libnm}" in "${filename}"
728 install_name_tool -change\
729 "${source}/lib/${dirname}/${version}${libnm}"\
730 "@executable_path/../${fwdir}/${version}${libnm}"\
738 echo Correct library id reference to "${libnm}" in "${target}"
739 install_name_tool -change\
740 "${source}/lib/${dirname}/${version}${libnm}"\
741 "@executable_path/../${fwdir}/${version}${libnm}"\
744 if [ ! -d "${condir}/translations" ]; then
745 mkdir -p "${condir}/translations"
747 echo Copy Qt translations to "${condir}/translations"
748 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
751 # -------------------------
752 # Create universal binaries
753 # -------------------------
754 convert_universal() {
756 for file in ${LYX_FILE_LIST} ; do
758 for arch in ${ARCH_LIST} ; do
759 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
760 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
763 if [ -n "${OBJ_LIST}" ]; then
764 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
766 if [ -f "${LibMagicInstallDir}/lib/${LibMagicLibrary}" -a "yes" = "${libmagic_deployment}" ]; then
767 private_framework LibMagic "${LibMagicInstallDir}/lib/${LibMagicLibrary}" "${LYX_BUNDLE_PATH}/${file}"
769 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
770 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
772 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
773 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
775 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
776 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
778 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
779 case "${reference}" in
780 *"${LyxBuildDir}"*"("*")")
781 echo ERROR: Bad reference to "${reference}" found!!
786 for arch in ${ARCH_LIST} ; do
787 rm -f ${BUNDLE_PATH}/*-${arch}
791 copy_dictionaries() {
792 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
793 ASpellResources="${LyxAppPrefix}/Contents/Resources"
794 # try to reuse macports dictionaries for now
795 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
796 mkdir -p "${ASpellResources}"
797 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
798 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
799 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
800 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
802 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
803 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
804 if [ -d "${DictionarySourceDir}" ]; then
805 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
808 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
809 MyThesResources="${LyxAppPrefix}/Contents/Resources"
810 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
814 set_bundle_display_options() {
817 Y_POSITION=$((Y_BOUNDS - 65))
818 Y_BOUNDS=$((Y_BOUNDS + 20))
819 LYX_X_POSITION=$((X_BOUNDS / 4))
820 LYX_Y_POSITION=$Y_POSITION
821 APP_X_POSITION=$((3 * X_BOUNDS / 4))
822 APP_Y_POSITION=$Y_POSITION
823 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
825 tell application "Finder"
826 set f to POSIX file ("${1}" as string) as alias
829 tell container window
830 set toolbar visible to false
831 set statusbar visible to false
832 set current view to icon view
834 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
837 set icon size of the icon view options of container window to 64
838 set arrangement of the icon view options of container window to not arranged
839 if ${WITH_DOCUMENTS} then
840 set position of item "Documents" to {$LYX_X_POSITION,0}
842 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
843 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
844 set background picture of the icon view options\
845 of container window to file "background.png" of folder "Pictures"
846 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
847 update without registering applications
859 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
860 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
861 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
863 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
865 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
866 # Unmount currently mounted disk image
867 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
869 # Mount the disk image
870 hdiutil attach "${DMGNAME}.sparseimage"
872 # Obtain device information
873 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
874 DEV=$(echo $DEVS | cut -f 1 -d ' ')
875 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
877 # copy in the application bundle
878 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
880 # copy in background image
881 mkdir -p "${VOLUME}/Pictures"
882 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
883 # symlink applications
884 ln -s /Applications/ "${VOLUME}"/Applications
885 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
886 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
887 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
888 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
890 # Unmount the disk image
891 hdiutil detach ${DEV}
893 # Convert the disk image to read-only
894 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
895 rm -f "${DMGNAME}.sparseimage"
898 # ------------------------------
899 # Building distribution packages
900 # ------------------------------
903 test -n "${LyxAppZip}" && (
904 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
908 for arch in ${ARCH_LIST} ; do
909 DMGARCH="${DMGARCH}-${arch}"
911 QtDmgArchSuffix=${QtMajorVersion}${DMGARCH}${QtAPI}.dmg
913 test -n "${DMGLocation}" && (
914 make_dmg "${DMGLocation}"
915 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
916 rm -f "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
917 echo move to "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
918 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
923 # ------------------------------
925 # ------------------------------
927 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then