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 (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
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"
60 QtConfigureOptions="${QtConfigureOptions} -fast -no-strip"
61 QtConfigureOptions="${QtConfigureOptions} -no-javascript-jit -no-pkg-config"
62 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
66 QtConfigureOptions="${QtConfigureOptions} -no-strip"
67 QtConfigureOptions="${QtConfigureOptions} -no-kms -no-pkg-config"
68 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake tools"
69 QtConfigureOptions="${QtConfigureOptions} -skip qtquick1 -skip qtwebkit -skip qtconnectivity -skip qtscript"
70 QtConfigureOptions="${QtConfigureOptions} -skip qtquickcontrols -skip qtdeclarative"
74 QtConfigureOptions="${QtConfigureOptions} -fast -no-exceptions"
75 QtConfigureOptions="${QtConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
76 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
77 QtConfigureOptions="${QtConfigureOptions} ${QtAPI}"
81 aspell_dictionaries="no"
82 hunspell_dictionaries="yes"
84 libmagic_deployment="yes"
85 aspell_deployment="yes"
86 hunspell_deployment="yes"
87 thesaurus_deployment="yes"
91 # auto detect Xcode location
92 if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
93 DEVELOPER_SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
94 XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
95 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
96 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.7.sdk" # Lion build is default
97 elif [ -d "/Developer/SDKs" ]; then
98 DEVELOPER_SDKS="/Developer/SDKs"
99 XCODE_DEVELOPER="/Developer"
100 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
101 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
104 # detection of script home
105 LyxSourceDir=$(dirname "$0")
106 if [ ! -d "${LyxSourceDir}" ]; then
107 echo Missing LyX source directory.
110 case "${LyxSourceDir}" in
112 LyxSourceDir=$(dirname "${LyxSourceDir}")
116 */development|development)
117 LyxSourceDir=$(dirname "${LyxSourceDir}")
118 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
121 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
126 echo "*" Build script for LyX on Mac OS X
128 echo Optional arguments:
129 echo " --aspell-deployment=yes|no ." default yes
130 echo " --with-qt-frameworks=yes|no." default no
131 echo " --qt-deployment=yes|no ....." default yes
132 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
133 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
134 echo " --with-arch=ARCH ..........." default ppc,i386
135 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
136 echo " --with-dmg-location=PATH ..." default \${build-path}
137 echo " --with-binary-strip=yes ...." default no
139 echo "All other arguments with -- are passed to configure"
140 echo "including the defaults: ${LyXConfigureOptions}"
145 if [ -x "${LyxSourceDir}/configure" ]; then
147 echo "*" Configure options of LyX
149 "${LyxSourceDir}/configure" --help
155 NCPU=$(sysctl -n hw.ncpu)
157 if [ $NCPU -gt 1 ]; then
161 while [ $# -gt 0 ]; do
163 --with-qt-frameworks=*)
164 configure_qt_frameworks=$(echo ${1}|cut -d= -f2)
165 if [ "$configure_qt_frameworks" = "yes" ]; then
172 QTDIR=$(echo ${1}|cut -d= -f2)
175 --with-macosx-target=*)
176 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
180 SDKROOT=$(echo ${1}|cut -d= -f2)
183 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
189 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
197 --libmagic-deployment=*)
198 libmagic_deployment=$(echo ${1}|cut -d= -f2)
201 --aspell-deployment=*)
202 aspell_deployment=$(echo ${1}|cut -d= -f2)
203 aspell_dictionaries=$aspell_deployment
206 --hunspell-deployment=*)
207 hunspell_deployment=$(echo ${1}|cut -d= -f2)
208 hunspell_dictionaries=$hunspell_deployment
211 --thesaurus-deployment=*)
212 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
216 qt_deployment=$(echo ${1}|cut -d= -f2)
220 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
221 ARCH_LIST="${ARCH_LIST} ${ARCH}"
224 --with-dmg-location=*)
225 DMGLocation=$(echo ${1}|cut -d= -f2)
228 --with-binary-strip=yes)
233 LyxBuildDir=$(echo ${1}|cut -d= -f2)
237 LyXUtilitiesDir=$(echo ${1}|cut -d= -f2)
244 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
245 aspell_deployment="no"
249 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
250 hunspell_deployment="no"
254 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
258 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
267 if [ "${configure_qt_frameworks}" != "yes" ]; then
268 QtInstallDir=${QTDIR:-"/opt/qt4"}
271 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
275 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
276 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
278 LyXUtilitiesDir=${LyXUtilitiesDir:-"${LyxBuildDir}"/utilities}
280 LibMagicSourceDir=${LIBMAGICDIR:-$(dirname "${LyxSourceDir}")/${LibMagicSource}}
281 LibMagicBuildDir="${LyxBuildDir}"/"${LibMagicSource}"
282 LibMagicInstallDir=${LibMagicInstallDir:-"${LyXUtilitiesDir}"}
283 LibMagicInstallHdr="${LibMagicInstallDir}/include/magic.h"
285 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
286 ASpellBuildDir="${ASpellSourceDir}"
287 ASpellInstallDir=${ASpellInstallDir:-"${LyXUtilitiesDir}"}
288 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
290 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
291 HunSpellBuildDir="${HunSpellSourceDir}"
292 HunSpellInstallDir=${HunSpellInstallDir:-"${LyXUtilitiesDir}"}
293 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
295 QtSourceDir=${QTSOURCEDIR:-$(dirname "${LyxSourceDir}")/${QtSourceVersion}}
296 QtBuildDir=${QtBuildDir:-"${LyxBuildDir}"/${QtBuildSubDir:-"qt-build"}}
298 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
299 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
300 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
302 if [ -z "${LyXVersion}" ]; then
303 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
305 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
306 case "${LyXVersion}" in
308 LyXGitCommitHash=$(cd "${LyxSourceDir}" ; git log -1 --pretty=format:%H)
313 LyxBase="${LyxName}-${LyXVersion}"
314 LyxApp="${LyxBase}.app"
315 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
316 LyxBuildDir="${LyxAppDir}.build"
317 LyxAppPrefix="${LyxAppDir}.app"
318 # if zip file is needed... remove the comment sign
319 #LyxAppZip="${LyxAppPrefix}.zip"
321 # ---------------------------------
322 # DON'T MODIFY ANYTHING BELOW HERE!
323 # ---------------------------------
325 # don't change order here...
326 case "${QtVersion}" in
328 QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
329 QtFrameworkVersion="5"
332 QtLibraries="QtSvg QtXml QtPrintSupport QtMacExtras QtWidgets QtGui QtNetwork QtConcurrent QtCore"
333 QtFrameworkVersion="5"
336 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
337 QtFrameworkVersion="4"
344 # Check for existing SDKs
345 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
350 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
351 case "${MACOSX_DEPLOYMENT_TARGET}" in
353 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
356 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
361 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
362 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
365 echo Unknown or missing SDK for Mac OS X.
369 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
371 if [ "${configure_qt_frameworks}" != "yes" -a -d "${QtSourceDir}" -a ! \( -d "${QtBuildDir}" -a -d "${QtInstallDir}" \) ]; then
372 echo Build Qt library ${QtSourceDir}
373 if [ "${QtInstallDir}" = "${QtBuildDir}" ]; then
374 echo Bad install directory for Qt.
375 echo Must be different from build directory "${QtBuildDir}".
379 mkdir -p "${QtBuildDir}" && cd "${QtBuildDir}"
380 for arch in ${ARCH_LIST} ; do
381 ARCHS="${ARCHS} -arch ${arch}"
383 echo configure options:
384 echo ${QtConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
385 "${QtSourceDir}"/configure ${QtConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
386 make ${MAKEJOBS} && make install
388 cd "${QtInstallDir}" && (
391 for libnm in ${QtLibraries} ; do
392 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
397 if [ -d "${LibMagicSourceDir}" -a ! -f "${LibMagicInstallHdr}" ]; then
398 # we have a private libmagic (file(1)) source tree at hand...
399 # so let's build and install it
400 if [ -z "${LibMagicVersion}" ]; then
401 LibMagicVersion=$(grep AC_INIT "${LibMagicSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
404 LibMagicName="LibMagic"
405 LibMagicBase="${LibMagicName}-${LibMagicVersion}"
407 echo Build libmagic library ${LibMagicBase}
408 echo configure options:
409 echo --prefix="${LibMagicInstallDir}" ${LibMagicConfigureOptions}
411 mkdir -p "${LibMagicBuildDir}" && cd "${LibMagicBuildDir}"
413 # ----------------------------------------
414 # Build LibMagic for different architectures
415 # ----------------------------------------
416 FILE_LIST="${LibMagicLibrary}"
418 for arch in ${ARCH_LIST} ; do
419 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
420 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
421 "${LibMagicSourceDir}/configure"\
422 --prefix="${LibMagicInstallDir}"\
423 ${LibMagicConfigureOptions}
424 make && make install${strip}
425 for file in ${FILE_LIST} ; do
426 if [ -f "${LibMagicInstallDir}"/lib/${file} ]; then
427 mv "${LibMagicInstallDir}"/lib/${file}\
428 "${LibMagicInstallDir}"/lib/${file}-${arch}
430 echo Cannot build and install LibMagic for ${arch}.
435 # -------------------------
436 # Create universal binaries
437 # -------------------------
438 for file in ${FILE_LIST} ; do
440 for arch in ${ARCH_LIST} ; do
441 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
444 cd "${LibMagicInstallDir}"
445 lipo -create ${OBJ_LIST} -o lib/${file}
446 # check for the "missing link"...
447 test -f lib/libmagic.dylib || (cd lib ; ln -s "${LibMagicLibrary}" libmagic.dylib)
453 for arch in ${ARCH_LIST} ; do
454 rm -f "${LibMagicInstallDir}"/lib/*-${arch}
458 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
459 # we have a private HunSpell source tree at hand...
460 # so let's build and install it
461 if [ -z "${HunSpellVersion}" ]; then
462 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
465 HunSpellName="Hunspell"
466 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
468 echo Build hunspell library ${HunSpellBase}
469 echo configure options:
470 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
472 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
474 # ----------------------------------------
475 # Build HunSpell for different architectures
476 # ----------------------------------------
477 FILE_LIST="${HunSpellLibrary}"
479 for arch in ${ARCH_LIST} ; do
481 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
482 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
483 "${HunSpellSourceDir}/configure"\
484 --prefix="${HunSpellInstallDir}"\
485 ${HunspellConfigureOptions}
486 make && make install${strip}
487 for file in ${FILE_LIST} ; do
488 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
489 mv "${HunSpellInstallDir}"/lib/${file}\
490 "${HunSpellInstallDir}"/lib/${file}-${arch}
492 echo Cannot build and install HunSpell for ${arch}.
497 # -------------------------
498 # Create universal binaries
499 # -------------------------
500 for file in ${FILE_LIST} ; do
502 for arch in ${ARCH_LIST} ; do
503 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
506 cd "${HunSpellInstallDir}"
507 lipo -create ${OBJ_LIST} -o lib/${file}
508 # check for the "missing link"...
509 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
515 for arch in ${ARCH_LIST} ; do
516 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
520 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
521 # we have a private ASpell source tree at hand...
522 # so let's build and install it
523 if [ -z "${ASpellVersion}" ]; then
524 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
528 ASpellBase="${ASpellName}-${ASpellVersion}"
530 echo Build aspell library ${ASpellBase}
531 echo configure options:
532 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
534 # ASpell builds inplace only :(
535 cd "${ASpellSourceDir}"
537 # ----------------------------------------
538 # Build ASpell for different architectures
539 # ----------------------------------------
540 FILE_LIST="${ASpellLibrary}"
542 for arch in ${ARCH_LIST} ; do
544 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
545 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
546 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
547 --prefix="${ASpellInstallDir}"\
548 ${AspellConfigureOptions}
549 make && make install${aspellstrip}
550 for file in ${FILE_LIST} ; do
551 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
552 mv "${ASpellInstallDir}"/lib/${file}\
553 "${ASpellInstallDir}"/lib/${file}-${arch}
555 echo Cannot build and install ASpell for ${arch}.
560 # -------------------------
561 # Create universal binaries
562 # -------------------------
563 for file in ${FILE_LIST} ; do
565 for arch in ${ARCH_LIST} ; do
566 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
569 cd "${ASpellInstallDir}"
570 lipo -create ${OBJ_LIST} -o lib/${file}
576 for arch in ${ARCH_LIST} ; do
577 rm -f "${ASpellInstallDir}"/lib/*-${arch}
583 echo "Frameworks/${1}.framework"
586 LYX_FILE_LIST="lyx lyxclient tex2lyx"
587 BUNDLE_PATH="Contents/MacOS"
588 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
591 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
592 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
594 # -------------------------------------
595 # Automate configure check
596 # -------------------------------------
597 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
598 ( cd "${LyxSourceDir}" && sh autogen.sh )
600 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
601 dname=$(dirname "$file")
602 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
603 ( cd "${LyxSourceDir}" && sh autogen.sh )
608 # -------------------------------------
609 # Build LyX for different architectures
610 # -------------------------------------
612 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
613 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
614 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
617 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
618 HunSpellFramework=$(framework_name Hunspell)
619 HunSpellFramework=$(basename "${HunSpellFramework}")
620 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
621 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
622 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
624 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
625 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
627 for arch in ${ARCH_LIST} ; do
629 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
630 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
632 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
633 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
635 if [ -n "${LyXGitCommitHash}" ]; then
636 CPPFLAGS="${CPPFLAGS} -DLYX_GIT_COMMIT_HASH='${LyXGitCommitHash}'"
639 if [ "$configure_qt_frameworks" = "yes" ]; then
640 export QT_CORE_CFLAGS="-FQtCore"
641 export QT_CORE_LIBS="-framework QtCore"
642 export QT_FRONTEND_CFLAGS="-FQtGui"
643 export QT_FRONTEND_LIBS="-framework QtGui"
644 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
645 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
648 echo LDFLAGS="${LDFLAGS}"
650 echo CPPFLAGS="${CPPFLAGS}"
652 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"}
653 "${LyxSourceDir}/configure"\
654 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
655 ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"} \
656 ${LyXConfigureOptions}\
657 --enable-build-type=rel && \
658 make ${MAKEJOBS} && make install${strip}
659 for file in ${LYX_FILE_LIST} ; do
660 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
661 mv "${LYX_BUNDLE_PATH}/${file}"\
662 "${LYX_BUNDLE_PATH}/${file}-${arch}"
664 echo ERROR: Cannot build and install LyX for ${arch}.
671 content_directory() {
673 content=$(dirname "${target}")
674 content=$(dirname "${content}")
678 private_framework() {
679 fwdir=$(framework_name "$1")
682 condir=$(content_directory "${target}")
683 libnm=$(basename "${source}")
684 mkdir -p "${condir}/${fwdir}"
685 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
686 cp -p "${source}" "${condir}/${fwdir}"
687 echo Set library id in "${condir}/${fwdir}/${libnm}"
688 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
690 echo Correct library id reference to "${libnm}" in "${target}"
691 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
695 source="${QtInstallDir}"
697 version="Versions/${QtFrameworkVersion}/"
698 condir=$(content_directory "${target}")
699 mkdir -p "${condir}/Resources"
700 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
703 Translations = translations
705 if [ ! -d "${condir}/PlugIns" ]; then
706 mkdir -p "${condir}/PlugIns"
707 find "${source}/plugins" -name \*.dylib -print | grep -v _debug.dylib | while read libname ; do
708 echo Copy plugin "${libname}"
709 dylib=$(basename "${libname}")
710 dirname=$(dirname "${libname}")
711 dirname=$(basename "${dirname}")
712 mkdir -p "${condir}/PlugIns/${dirname}"
713 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
716 for libnm in ${QtLibraries} ; do
717 fwdir=$(framework_name "$libnm")
718 dirname=$(dirname "${fwdir}")
719 mkdir -p "${condir}/${dirname}"
720 dirname=$(basename "${fwdir}")
721 test -d "${condir}/${fwdir}" || (
722 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
723 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
724 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
725 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
726 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
727 if [ "${filename}" != "${target}" ]; then
728 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
729 # pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
731 *"${libnm}"*"("*version*")"*)
732 echo Correct library id reference to "${libnm}" in "${filename}"
733 install_name_tool -change\
734 "${source}/lib/${dirname}/${version}${libnm}"\
735 "@executable_path/../${fwdir}/${version}${libnm}"\
743 echo Correct library id reference to "${libnm}" in "${target}"
744 install_name_tool -change\
745 "${source}/lib/${dirname}/${version}${libnm}"\
746 "@executable_path/../${fwdir}/${version}${libnm}"\
749 if [ ! -d "${condir}/translations" ]; then
750 mkdir -p "${condir}/translations"
752 echo Copy Qt translations to "${condir}/translations"
753 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
756 # -------------------------
757 # Create universal binaries
758 # -------------------------
759 convert_universal() {
761 for file in ${LYX_FILE_LIST} ; do
763 for arch in ${ARCH_LIST} ; do
764 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
765 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
768 if [ -n "${OBJ_LIST}" ]; then
769 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
771 if [ -f "${LibMagicInstallDir}/lib/${LibMagicLibrary}" -a "yes" = "${libmagic_deployment}" ]; then
772 private_framework LibMagic "${LibMagicInstallDir}/lib/${LibMagicLibrary}" "${LYX_BUNDLE_PATH}/${file}"
774 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
775 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
777 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
778 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
780 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
781 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
783 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
784 case "${reference}" in
785 *"${LyxBuildDir}"*"("*")")
786 echo ERROR: Bad reference to "${reference}" found!!
791 for arch in ${ARCH_LIST} ; do
792 rm -f ${BUNDLE_PATH}/*-${arch}
796 copy_dictionaries() {
797 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
798 ASpellResources="${LyxAppPrefix}/Contents/Resources"
799 # try to reuse macports dictionaries for now
800 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
801 mkdir -p "${ASpellResources}"
802 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
803 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
804 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
805 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
807 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
808 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
809 if [ -d "${DictionarySourceDir}" ]; then
810 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
813 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
814 MyThesResources="${LyxAppPrefix}/Contents/Resources"
815 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
819 set_bundle_display_options() {
822 Y_POSITION=$((Y_BOUNDS - 65))
823 Y_BOUNDS=$((Y_BOUNDS + 20))
824 LYX_X_POSITION=$((X_BOUNDS / 4))
825 LYX_Y_POSITION=$Y_POSITION
826 APP_X_POSITION=$((3 * X_BOUNDS / 4))
827 APP_Y_POSITION=$Y_POSITION
828 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
830 tell application "Finder"
831 set f to POSIX file ("${1}" as string) as alias
834 tell container window
835 set toolbar visible to false
836 set statusbar visible to false
837 set current view to icon view
839 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
842 set icon size of the icon view options of container window to 64
843 set arrangement of the icon view options of container window to not arranged
844 if ${WITH_DOCUMENTS} then
845 set position of item "Documents" to {$LYX_X_POSITION,0}
847 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
848 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
849 set background picture of the icon view options\
850 of container window to file "background.png" of folder "Pictures"
851 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
852 update without registering applications
864 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
865 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
866 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
868 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
870 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
871 # Unmount currently mounted disk image
872 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
874 # Mount the disk image
875 hdiutil attach "${DMGNAME}.sparseimage"
877 # Obtain device information
878 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
879 DEV=$(echo $DEVS | cut -f 1 -d ' ')
880 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
882 # copy in the application bundle
883 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
885 # copy in background image
886 mkdir -p "${VOLUME}/Pictures"
887 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
888 # symlink applications
889 ln -s /Applications/ "${VOLUME}"/Applications
890 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
891 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
892 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
893 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
895 # Unmount the disk image
896 hdiutil detach ${DEV}
898 # Convert the disk image to read-only
899 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
900 rm -f "${DMGNAME}.sparseimage"
903 # ------------------------------
904 # Building distribution packages
905 # ------------------------------
908 test -n "${LyxAppZip}" && (
909 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
913 for arch in ${ARCH_LIST} ; do
914 DMGARCH="${DMGARCH}-${arch}"
916 QtDmgArchSuffix=${QtMajorVersion}${DMGARCH}${QtAPI}.dmg
918 test -n "${DMGLocation}" && (
919 make_dmg "${DMGLocation}"
920 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
921 rm -f "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
922 echo move to "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
923 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
928 # ------------------------------
930 # ------------------------------
932 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then