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="${Qt4ConfigureOptions} -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="${Qt4ConfigureOptions} ${Qt4API}"
60 aspell_dictionaries="no"
61 hunspell_dictionaries="yes"
63 gettext_deployment="yes"
64 aspell_deployment="yes"
65 hunspell_deployment="yes"
66 thesaurus_deployment="yes"
70 # auto detect Xcode location
71 if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
72 DEVELOPER_SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
73 XCODE_DEVELOPER="/Applications/Xcode.app/Contents/Developer"
74 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
75 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.7.sdk" # Lion build is default
76 elif [ -d "/Developer/SDKs" ]; then
77 DEVELOPER_SDKS="/Developer/SDKs"
78 XCODE_DEVELOPER="/Developer"
79 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
80 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
83 # detection of script home
84 LyxSourceDir=$(dirname "$0")
85 if [ ! -d "${LyxSourceDir}" ]; then
86 echo Missing LyX source directory.
89 case "${LyxSourceDir}" in
91 LyxSourceDir=$(dirname "${LyxSourceDir}")
95 */development|development)
96 LyxSourceDir=$(dirname "${LyxSourceDir}")
97 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
100 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
105 echo "*" Build script for LyX on Mac OS X
107 echo Optional arguments:
108 echo " --aspell-deployment=yes|no ." default yes
109 echo " --with-qt4-frameworks=yes|no" default no
110 echo " --qt4-deployment=yes|no ...." default yes
111 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
112 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
113 echo " --with-arch=ARCH ..........." default ppc,i386
114 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
115 echo " --with-dmg-location=PATH ..." default \${build-path}
117 echo "All other arguments with -- are passed to configure"
118 echo "including the defaults: ${LyXConfigureOptions}"
119 if [ -x "${LyxSourceDir}/configure" ]; then
121 echo "*" Configure options of LyX
123 "${LyxSourceDir}/configure" --help
128 while [ $# -gt 0 ]; do
130 --with-qt4-frameworks=*)
131 configure_qt4_frameworks=$(echo ${1}|cut -d= -f2)
132 if [ "$configure_qt4_frameworks" = "yes" ]; then
139 QTDIR=$(echo ${1}|cut -d= -f2)
142 --with-macosx-target=*)
143 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
147 SDKROOT=$(echo ${1}|cut -d= -f2)
150 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
156 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
164 --gettext-deployment=*)
165 gettext_deployment=$(echo ${1}|cut -d= -f2)
168 --aspell-deployment=*)
169 aspell_deployment=$(echo ${1}|cut -d= -f2)
170 aspell_dictionaries=$aspell_deployment
173 --hunspell-deployment=*)
174 hunspell_deployment=$(echo ${1}|cut -d= -f2)
175 hunspell_dictionaries=$hunspell_deployment
178 --thesaurus-deployment=*)
179 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
183 qt4_deployment=$(echo ${1}|cut -d= -f2)
187 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
188 ARCH_LIST="${ARCH_LIST} ${ARCH}"
191 --with-dmg-location=*)
192 DMGLocation=$(echo ${1}|cut -d= -f2)
196 LyxBuildDir=$(echo ${1}|cut -d= -f2)
203 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
204 aspell_deployment="no"
208 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
209 hunspell_deployment="no"
213 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
217 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
226 if [ "${configure_qt4_frameworks}" != "yes" ]; then
227 QtInstallDir=${QTDIR:-"/opt/qt4"}
229 QtFrameworkVersion="4"
231 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
236 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
237 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
239 GettextSourceDir=${GETTEXTDIR:-$(dirname "${LyxSourceDir}")/${GettextSource}}
240 GettextBuildDir="${LyxBuildDir}"/"${GettextSource}"
241 GettextInstallDir=${GettextInstallDir:-"${LyxBuildDir}"/utilities}
242 GettextInstallHdr="${GettextInstallDir}/include/libintl.h"
244 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
245 ASpellBuildDir="${ASpellSourceDir}"
246 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/utilities}
247 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
249 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
250 HunSpellBuildDir="${HunSpellSourceDir}"
251 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/utilities}
252 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
254 Qt4SourceDir=${QT4SOURCEDIR:-$(dirname "${LyxSourceDir}")/${Qt4SourceVersion}}
255 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4BuildSubDir:-"qt4-build"}}
257 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
258 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
259 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
261 if [ -z "${LyXVersion}" ]; then
262 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
264 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
267 LyxBase="${LyxName}-${LyXVersion}"
268 LyxApp="${LyxBase}.app"
269 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
270 LyxBuildDir="${LyxAppDir}.build"
271 LyxAppPrefix="${LyxAppDir}.app"
272 # if zip file is needed... remove the comment sign
273 #LyxAppZip="${LyxAppPrefix}.zip"
275 # ---------------------------------
276 # DON'T MODIFY ANYTHING BELOW HERE!
277 # ---------------------------------
279 # don't change order here...
280 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
285 # Check for existing SDKs
286 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
291 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
292 case "${MACOSX_DEPLOYMENT_TARGET}" in
294 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
297 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
302 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
303 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
306 echo Unknown or missing SDK for Mac OS X.
310 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
312 # These variables define the identifiers of the
313 # system (both Intel and PowerPC) to compile for.
314 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
315 # Only change these if necessary
317 HostSystem_i386="i686-apple-darwin8"
318 HostSystem_ppc="powerpc-apple-darwin8"
320 if [ "${configure_qt4_frameworks}" != "yes" -a -d "${Qt4SourceDir}" -a ! \( -d "${Qt4BuildDir}" -a -d "${QtInstallDir}" \) ]; then
321 echo Build Qt4 library ${Qt4SourceDir}
322 if [ "${QtInstallDir}" = "${Qt4BuildDir}" ]; then
323 echo Bad install directory for Qt.
324 echo Must be different from build directory "${Qt4BuildDir}".
328 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
329 for arch in ${ARCH_LIST} ; do
330 ARCHS="${ARCHS} -arch ${arch}"
332 echo configure options:
333 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
334 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
337 cd "${QtInstallDir}" && (
340 for libnm in ${QtLibraries} ; do
341 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
346 if [ -d "${GettextSourceDir}" -a ! -f "${GettextInstallHdr}" ]; then
347 # we have a private Gettext source tree at hand...
348 # so let's build and install it
349 if [ -z "${GettextVersion}" ]; then
350 GettextVersion=$(grep AC_INIT "${GettextSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
353 GettextName="Gettext"
354 GettextBase="${GettextName}-${GettextVersion}"
356 echo Build gettext library ${GettextBase}
357 echo configure options:
358 echo --prefix="${GettextInstallDir}" ${GettextConfigureOptions}
360 mkdir -p "${GettextBuildDir}" && cd "${GettextBuildDir}"
362 # ----------------------------------------
363 # Build Gettext for different architectures
364 # ----------------------------------------
365 FILE_LIST="${GettextLibrary}"
367 for arch in ${ARCH_LIST} ; do
368 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
369 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
370 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
371 "${GettextSourceDir}/configure"\
372 --prefix="${GettextInstallDir}"\
373 ${GettextConfigureOptions}
374 make && make install${strip}
375 for file in ${FILE_LIST} ; do
376 if [ -f "${GettextInstallDir}"/lib/${file} ]; then
377 mv "${GettextInstallDir}"/lib/${file}\
378 "${GettextInstallDir}"/lib/${file}-${arch}
380 echo Cannot build and install Gettext for ${arch}.
385 # -------------------------
386 # Create universal binaries
387 # -------------------------
388 for file in ${FILE_LIST} ; do
390 for arch in ${ARCH_LIST} ; do
391 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
394 cd "${GettextInstallDir}"
395 lipo -create ${OBJ_LIST} -o lib/${file}
401 for arch in ${ARCH_LIST} ; do
402 rm -f "${GettextInstallDir}"/lib/*-${arch}
406 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
407 # we have a private HunSpell source tree at hand...
408 # so let's build and install it
409 if [ -z "${HunSpellVersion}" ]; then
410 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
413 HunSpellName="Hunspell"
414 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
416 echo Build hunspell library ${HunSpellBase}
417 echo configure options:
418 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
420 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
422 # ----------------------------------------
423 # Build HunSpell for different architectures
424 # ----------------------------------------
425 FILE_LIST="${HunSpellLibrary}"
427 for arch in ${ARCH_LIST} ; do
429 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
430 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
431 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
432 "${HunSpellSourceDir}/configure"\
433 --prefix="${HunSpellInstallDir}"\
434 ${HunspellConfigureOptions}
435 make && make install${strip}
436 for file in ${FILE_LIST} ; do
437 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
438 mv "${HunSpellInstallDir}"/lib/${file}\
439 "${HunSpellInstallDir}"/lib/${file}-${arch}
441 echo Cannot build and install HunSpell for ${arch}.
446 # -------------------------
447 # Create universal binaries
448 # -------------------------
449 for file in ${FILE_LIST} ; do
451 for arch in ${ARCH_LIST} ; do
452 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
455 cd "${HunSpellInstallDir}"
456 lipo -create ${OBJ_LIST} -o lib/${file}
457 # check for the "missing link"...
458 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
464 for arch in ${ARCH_LIST} ; do
465 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
469 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
470 # we have a private ASpell source tree at hand...
471 # so let's build and install it
472 if [ -z "${ASpellVersion}" ]; then
473 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
477 ASpellBase="${ASpellName}-${ASpellVersion}"
479 echo Build aspell library ${ASpellBase}
480 echo configure options:
481 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
483 # ASpell builds inplace only :(
484 cd "${ASpellSourceDir}"
486 # ----------------------------------------
487 # Build ASpell for different architectures
488 # ----------------------------------------
489 FILE_LIST="${ASpellLibrary}"
491 for arch in ${ARCH_LIST} ; do
493 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
494 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
495 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
496 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
497 --prefix="${ASpellInstallDir}"\
498 ${AspellConfigureOptions}
499 make && make install${aspellstrip}
500 for file in ${FILE_LIST} ; do
501 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
502 mv "${ASpellInstallDir}"/lib/${file}\
503 "${ASpellInstallDir}"/lib/${file}-${arch}
505 echo Cannot build and install ASpell for ${arch}.
510 # -------------------------
511 # Create universal binaries
512 # -------------------------
513 for file in ${FILE_LIST} ; do
515 for arch in ${ARCH_LIST} ; do
516 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
519 cd "${ASpellInstallDir}"
520 lipo -create ${OBJ_LIST} -o lib/${file}
526 for arch in ${ARCH_LIST} ; do
527 rm -f "${ASpellInstallDir}"/lib/*-${arch}
533 echo "Frameworks/${1}.framework"
536 LYX_FILE_LIST="lyx lyxclient tex2lyx"
537 BUNDLE_PATH="Contents/MacOS"
538 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
541 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
542 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
544 # -------------------------------------
545 # Automate configure check
546 # -------------------------------------
547 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
548 ( cd "${LyxSourceDir}" && sh autogen.sh )
550 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
551 dname=$(dirname "$file")
552 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
553 ( cd "${LyxSourceDir}" && sh autogen.sh )
558 # -------------------------------------
559 # Build LyX for different architectures
560 # -------------------------------------
562 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
563 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
564 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
567 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
568 HunSpellFramework=$(framework_name Hunspell)
569 HunSpellFramework=$(basename "${HunSpellFramework}")
570 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
571 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
572 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
574 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
575 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
577 for arch in ${ARCH_LIST} ; do
579 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
580 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
582 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
583 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
584 HOSTSYSTEM=$(eval "echo \\$HostSystem_$arch")
586 if [ "$configure_qt4_frameworks" = "yes" ]; then
587 export QT4_CORE_CFLAGS="-FQtCore"
588 export QT4_CORE_LIBS="-framework QtCore"
589 export QT4_FRONTEND_CFLAGS="-FQtGui"
590 export QT4_FRONTEND_LIBS="-framework QtGui"
592 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
593 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
596 echo LDFLAGS="${LDFLAGS}"
598 echo CPPFLAGS="${CPPFLAGS}"
600 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"}
601 "${LyxSourceDir}/configure"\
602 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
603 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
604 ${LyXConfigureOptions}\
605 --enable-build-type=rel && \
606 make -j2 && make install${strip}
607 for file in ${LYX_FILE_LIST} ; do
608 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
609 mv "${LYX_BUNDLE_PATH}/${file}"\
610 "${LYX_BUNDLE_PATH}/${file}-${arch}"
612 echo ERROR: Cannot build and install LyX for ${arch}.
619 content_directory() {
621 content=$(dirname "${target}")
622 content=$(dirname "${content}")
626 private_framework() {
627 fwdir=$(framework_name "$1")
630 condir=$(content_directory "${target}")
631 libnm=$(basename "${source}")
632 mkdir -p "${condir}/${fwdir}"
633 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
634 cp -p "${source}" "${condir}/${fwdir}"
635 echo Set library id in "${condir}/${fwdir}/${libnm}"
636 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
638 echo Correct library id reference to "${libnm}" in "${target}"
639 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
643 source="${QtInstallDir}"
645 version="Versions/${QtFrameworkVersion}/"
646 condir=$(content_directory "${target}")
647 mkdir -p "${condir}/Resources"
648 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
651 Translations = translations
653 if [ ! -d "${condir}/PlugIns" ]; then
654 mkdir -p "${condir}/PlugIns"
655 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
656 echo Copy plugin "${libname}"
657 dylib=$(basename "${libname}")
658 dirname=$(dirname "${libname}")
659 dirname=$(basename "${dirname}")
660 mkdir -p "${condir}/PlugIns/${dirname}"
661 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
664 for libnm in ${QtLibraries} ; do
665 fwdir=$(framework_name "$libnm")
666 dirname=$(dirname "${fwdir}")
667 mkdir -p "${condir}/${dirname}"
668 dirname=$(basename "${fwdir}")
669 test -d "${condir}/${fwdir}" || (
670 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
671 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
672 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
673 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
674 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
675 if [ "${filename}" != "${target}" ]; then
676 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
677 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
679 *"${libnm}"*"("*version*")"*)
680 echo Correct library id reference to "${libnm}" in "${filename}"
681 install_name_tool -change\
682 "${source}/lib/${dirname}/${version}${libnm}"\
683 "@executable_path/../${fwdir}/${version}${libnm}"\
691 echo Correct library id reference to "${libnm}" in "${target}"
692 install_name_tool -change\
693 "${source}/lib/${dirname}/${version}${libnm}"\
694 "@executable_path/../${fwdir}/${version}${libnm}"\
697 if [ ! -d "${condir}/translations" ]; then
698 mkdir -p "${condir}/translations"
700 echo Copy Qt translations to "${condir}/translations"
701 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
704 # -------------------------
705 # Create universal binaries
706 # -------------------------
707 convert_universal() {
709 for file in ${LYX_FILE_LIST} ; do
711 for arch in ${ARCH_LIST} ; do
712 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
713 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
716 if [ -n "${OBJ_LIST}" ]; then
717 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
719 if [ -f "${GettextInstallDir}/lib/${GettextLibrary}" -a "yes" = "${gettext_deployment}" ]; then
720 private_framework Gettext "${GettextInstallDir}/lib/${GettextLibrary}" "${LYX_BUNDLE_PATH}/${file}"
722 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
723 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
725 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
726 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
728 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
729 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
731 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
732 case "${reference}" in
733 *"${LyxBuildDir}"*"("*")")
734 echo ERROR: Bad reference to "${reference}" found!!
739 for arch in ${ARCH_LIST} ; do
740 rm -f ${BUNDLE_PATH}/*-${arch}
744 copy_dictionaries() {
745 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
746 ASpellResources="${LyxAppPrefix}/Contents/Resources"
747 # try to reuse macports dictionaries for now
748 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
749 mkdir -p "${ASpellResources}"
750 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
751 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
752 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
753 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
755 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
756 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
757 if [ -d "${DictionarySourceDir}" ]; then
758 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
761 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
762 MyThesResources="${LyxAppPrefix}/Contents/Resources"
763 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
767 set_bundle_display_options() {
770 Y_POSITION=$((Y_BOUNDS - 65))
771 Y_BOUNDS=$((Y_BOUNDS + 20))
772 LYX_X_POSITION=$((X_BOUNDS / 4))
773 LYX_Y_POSITION=$Y_POSITION
774 APP_X_POSITION=$((3 * X_BOUNDS / 4))
775 APP_Y_POSITION=$Y_POSITION
777 tell application "Finder"
778 set f to POSIX file ("${1}" as string) as alias
781 tell container window
782 set toolbar visible to false
783 set statusbar visible to false
784 set current view to icon view
786 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
789 set icon size of the icon view options of container window to 64
790 set arrangement of the icon view options of container window to not arranged
791 set position of item "Documents" to {$LYX_X_POSITION,0}
792 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
793 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
794 set background picture of the icon view options\
795 of container window to file "background.png" of folder "Pictures"
796 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
797 update without registering applications
809 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
810 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
811 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
813 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
815 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
816 # Unmount currently mounted disk image
817 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
819 # Mount the disk image
820 hdiutil attach "${DMGNAME}.sparseimage"
822 # Obtain device information
823 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
824 DEV=$(echo $DEVS | cut -f 1 -d ' ')
825 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
827 # copy in the application bundle
828 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
830 # copy in background image
831 mkdir -p "${VOLUME}/Pictures"
832 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
833 # symlink applications
834 ln -s /Applications/ "${VOLUME}"/Applications
835 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
836 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
837 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
838 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
840 # Unmount the disk image
841 hdiutil detach ${DEV}
843 # Convert the disk image to read-only
844 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
845 rm -f "${DMGNAME}.sparseimage"
848 # ------------------------------
849 # Building distribution packages
850 # ------------------------------
853 test -n "${LyxAppZip}" && (
854 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
857 test -n "${DMGLocation}" && (
858 make_dmg "${DMGLocation}"
859 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
860 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
861 echo move to "${DMGLocation}/${DMGNAME}+qt4${Qt4API}.dmg"
862 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4${Qt4API}.dmg"
867 # ------------------------------
869 # ------------------------------
871 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then