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.3"}
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 (only hunspell dicts and mythes thesauri are deployed per default):
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"
58 for arch in ${ARCH_LIST} ; do
59 QTARCHS="${QTARCHS} -arch ${arch}"
63 QtConfigureOptions="${QtConfigureOptions} -fast -no-strip"
64 QtConfigureOptions="${QtConfigureOptions} -no-javascript-jit -no-pkg-config"
65 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
69 QtConfigureOptions="${QtConfigureOptions} -no-strip"
70 QtConfigureOptions="${QtConfigureOptions} -no-kms -no-pkg-config"
71 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake tools"
72 QtConfigureOptions="${QtConfigureOptions} -skip qtconnectivity -skip qtscript"
73 QtConfigureOptions="${QtConfigureOptions} -skip qtquickcontrols"
74 QtConfigureOptions="${QtConfigureOptions} -skip qttools"
75 QtConfigureOptions="${QtConfigureOptions} -skip qtdeclarative"
79 QtConfigureOptions="${QtConfigureOptions} -no-strip"
80 QtConfigureOptions="${QtConfigureOptions} -no-kms -no-pkg-config"
81 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake tools"
82 QtConfigureOptions="${QtConfigureOptions} -skip qtquick1 -skip qtwebkit -skip qtconnectivity -skip qtscript"
83 QtConfigureOptions="${QtConfigureOptions} -skip qtquickcontrols"
84 # QtConfigureOptions="${QtConfigureOptions} -skip qtdeclarative"
88 QtConfigureOptions="${QtConfigureOptions} -fast -no-exceptions"
89 QtConfigureOptions="${QtConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
90 QtConfigureOptions="${QtConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
91 QtConfigureOptions="${QtConfigureOptions} ${QtAPI}"
92 for arch in ${ARCH_LIST} ; do
93 QTARCHS="${QTARCHS} -arch ${arch}"
98 aspell_dictionaries="no"
99 hunspell_dictionaries="yes"
101 libmagic_deployment="yes"
102 aspell_deployment="yes"
103 hunspell_deployment="yes"
104 thesaurus_deployment="yes"
108 # auto detect Xcode location
109 DEVELOPER_SDKS=$(dirname $(xcrun --show-sdk-path))
110 if [ -n "${DEVELOPER_SDKS}" ]; then
111 XCODE_DEVELOPER=$(dirname $(dirname $(xcrun --show-sdk-platform-path)))
112 MACOSX_DEPLOYMENT_TARGET="10.7" # Lion support is default
113 SDKROOT="${DEVELOPER_SDKS}/MacOSX$(xcrun --show-sdk-version).sdk" # use default SDK
114 elif [ -d "/Developer/SDKs" ]; then
115 DEVELOPER_SDKS="/Developer/SDKs"
116 XCODE_DEVELOPER="/Developer"
117 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
118 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.5.sdk" # Leopard build is default
121 # detection of script home
122 LyxSourceDir=$(dirname "$0")
123 if [ ! -d "${LyxSourceDir}" ]; then
124 echo Missing LyX source directory.
127 case "${LyxSourceDir}" in
129 LyxSourceDir=$(dirname "${LyxSourceDir}")
133 */development|development)
134 LyxSourceDir=$(dirname "${LyxSourceDir}")
135 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
138 LyxSourceDir=$(cd "${LyxSourceDir}";pwd)
143 echo "*" Build script for LyX on Mac OS X
145 echo Optional arguments:
146 echo " --aspell-deployment=yes|no ." default yes
147 echo " --with-qt-frameworks=yes|no." default no
148 echo " --qt-deployment=yes|no ....." default yes
149 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
150 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
151 echo " --with-arch=ARCH ..........." default ppc,i386
152 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
153 echo " --with-dmg-location=PATH ..." default \${build-path}
154 echo " --with-binary-strip=yes ...." default no
156 echo "All other arguments with -- are passed to configure"
157 echo "including the defaults: ${LyXConfigureOptions}"
162 if [ -x "${LyxSourceDir}/configure" ]; then
164 echo "*" Configure options of LyX
166 "${LyxSourceDir}/configure" --help
172 NCPU=$(sysctl -n hw.ncpu)
174 if [ $NCPU -gt 1 ]; then
178 while [ $# -gt 0 ]; do
180 --with-qt-frameworks=*)
181 configure_qt_frameworks=$(echo ${1}|cut -d= -f2)
182 if [ "$configure_qt_frameworks" = "yes" ]; then
189 QTDIR=$(echo ${1}|cut -d= -f2)
192 --with-macosx-target=*)
193 MACOSX_DEPLOYMENT_TARGET=$(echo ${1}|cut -d= -f2)
197 SDKROOT=$(echo ${1}|cut -d= -f2)
200 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.4u.sdk"
206 SDKROOT="${DEVELOPER_SDKS}/MacOSX${SDKROOT}.sdk"
207 if [ ! -d "${SDKROOT}" ]; then
208 echo Invalid SDKROOT given: "${SDKROOT}"
215 --libmagic-deployment=*)
216 libmagic_deployment=$(echo ${1}|cut -d= -f2)
219 --aspell-deployment=*)
220 aspell_deployment=$(echo ${1}|cut -d= -f2)
221 aspell_dictionaries=$aspell_deployment
224 --hunspell-deployment=*)
225 hunspell_deployment=$(echo ${1}|cut -d= -f2)
226 hunspell_dictionaries=$hunspell_deployment
229 --thesaurus-deployment=*)
230 thesaurus_deployment=$(echo ${1}|cut -d= -f2)
234 qt_deployment=$(echo ${1}|cut -d= -f2)
238 ARCH=$(echo ${1}|cut -d= -f2|tr ',' ' ')
239 ARCH_LIST="${ARCH_LIST} ${ARCH}"
242 --with-dmg-location=*)
243 DMGLocation=$(echo ${1}|cut -d= -f2)
246 --with-binary-strip=yes)
251 LyxBuildDir=$(echo ${1}|cut -d= -f2)
255 LyXUtilitiesDir=$(echo ${1}|cut -d= -f2)
262 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
263 aspell_deployment="no"
267 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
268 hunspell_deployment="no"
272 QtOnlyPackage=$(echo ${1}|cut -d= -f2)
276 LyxOnlyPackage=$(echo ${1}|cut -d= -f2)
280 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
281 EnableCXX11="--enable-cxx11"
285 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
294 if [ "${configure_qt_frameworks}" != "yes" ]; then
295 QtInstallDir=${QTDIR:-"/opt/qt4"}
298 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
302 LyxBuildDir=${LyxBuildDir:-$(dirname "${LyxSourceDir}")/lyx-build}
303 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
305 LyXUtilitiesDir=${LyXUtilitiesDir:-"${LyxBuildDir}"/utilities}
307 LibMagicSourceDir=${LIBMAGICDIR:-$(dirname "${LyxSourceDir}")/${LibMagicSource}}
308 LibMagicBuildDir="${LyxBuildDir}"/"${LibMagicSource}"
309 LibMagicInstallDir=${LibMagicInstallDir:-"${LyXUtilitiesDir}"}
310 LibMagicInstallHdr="${LibMagicInstallDir}/include/magic.h"
312 ASpellSourceDir=${ASPELLDIR:-$(dirname "${LyxSourceDir}")/${ASpellSource}}
313 ASpellBuildDir="${ASpellSourceDir}"
314 ASpellInstallDir=${ASpellInstallDir:-"${LyXUtilitiesDir}"}
315 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
317 HunSpellSourceDir=${HUNSPELLDIR:-$(dirname "${LyxSourceDir}")/${HunSpellSource}}
318 HunSpellBuildDir="${HunSpellSourceDir}"
319 HunSpellInstallDir=${HunSpellInstallDir:-"${LyXUtilitiesDir}"}
320 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
322 QtSourceDir=${QTSOURCEDIR:-$(dirname "${LyxSourceDir}")/${QtSourceVersion}}
323 QtBuildDir=${QtBuildDir:-"${LyxBuildDir}"/${QtBuildSubDir:-"qt-build"}}
325 DictionarySourceDir=${DICTIONARYDIR:-$(dirname "${LyxSourceDir}")/dictionaries}
326 DocumentationDir=$(dirname "${LyxSourceDir}")/Documents
327 DmgBackground="${LyxSourceDir}"/development/MacOSX/dmg-background.png
329 if [ -z "${LyXVersion}" ]; then
330 LyXVersion=$(grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()")
332 LyXVersionSuffix=${LyXVersionSuffix:-$(echo "${LyXVersion}" | cut -d. -f1-2)}
333 case "${LyXVersion}" in
335 LyXGitCommitHash=$(cd "${LyxSourceDir}" ; git log -1 --pretty=format:%h)
340 LyxBase="${LyxName}-${LyXVersion}"
341 LyxApp="${LyxBase}.app"
342 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
343 LyxBuildDir="${LyxAppDir}.build"
344 LyxAppPrefix="${LyxAppDir}.app"
345 # if zip file is needed... remove the comment sign
346 #LyxAppZip="${LyxAppPrefix}.zip"
348 # ---------------------------------
349 # DON'T MODIFY ANYTHING BELOW HERE!
350 # ---------------------------------
352 # don't change order here...
353 case "${QtVersion}" in
355 QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
356 QtFrameworkVersion="5"
359 QtLibraries="QtSvg QtXml QtPrintSupport QtMacExtras QtWidgets QtGui QtNetwork QtConcurrent QtCore"
360 QtFrameworkVersion="5"
363 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
364 QtFrameworkVersion="4"
368 DMGNAME="${LyxBase}${LyXGitCommitHash:+-}${LyXGitCommitHash}"
371 # Check for existing SDKs
372 SDKs=$(echo ${DEVELOPER_SDKS}/MacOSX10*sdk)
377 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
378 case "${MACOSX_DEPLOYMENT_TARGET}" in
380 SDKROOT="${DEVELOPER_SDKS}/MacOSX10.6.sdk"; export SDKROOT
383 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
388 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
389 SDKROOT=${SDKROOT:-"${DEVELOPER_SDKS}/MacOSX10.5.sdk"}; export SDKROOT
392 echo Unknown or missing SDK for Mac OS X.
396 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
399 echo Build Qt library ${QtSourceDir}
400 if [ "${QtInstallDir}" = "${QtBuildDir}" ]; then
401 echo Bad install directory for Qt.
402 echo Must be different from build directory "${QtBuildDir}".
406 mkdir -p "${QtBuildDir}" && cd "${QtBuildDir}"
407 echo configure options:
408 echo ${QtConfigureOptions} ${QTARCHS} -prefix "${QtInstallDir}"
409 "${QtSourceDir}"/configure ${QtConfigureOptions} ${QTARCHS} -prefix "${QtInstallDir}"
410 make -j1 && make -j1 install
412 if [ -d "${QtInstallDir}" -a ! -f "${QtInstallDir}"/include/QtCore ]; then
413 cd "${QtInstallDir}" && (
416 for libnm in ${QtLibraries} ; do
417 test -d ${libnm} -o -L ${libnm} || \
418 ( ln -s ../lib/${libnm}.framework/Headers ${libnm} && echo Link to framework ${libnm} )
424 case ${QtOnlyPackage:-"no"} in
430 if [ "${configure_qt_frameworks}" != "yes" -a -d "${QtSourceDir}" -a ! \( -d "${QtBuildDir}" -a -d "${QtInstallDir}" \) ]; then
436 if [ -d "${LibMagicSourceDir}" -a ! -f "${LibMagicInstallHdr}" ]; then
437 # we have a private libmagic (file(1)) source tree at hand...
438 # so let's build and install it
439 if [ -z "${LibMagicVersion}" ]; then
440 LibMagicVersion=$(grep AC_INIT "${LibMagicSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
443 LibMagicName="LibMagic"
444 LibMagicBase="${LibMagicName}-${LibMagicVersion}"
446 echo Build libmagic library ${LibMagicBase}
447 echo configure options:
448 echo --prefix="${LibMagicInstallDir}" ${LibMagicConfigureOptions}
450 mkdir -p "${LibMagicBuildDir}" && cd "${LibMagicBuildDir}"
452 # ----------------------------------------
453 # Build LibMagic for different architectures
454 # ----------------------------------------
455 FILE_LIST="${LibMagicLibrary}"
457 for arch in ${ARCH_LIST} ; do
458 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
459 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
460 "${LibMagicSourceDir}/configure"\
461 --prefix="${LibMagicInstallDir}"\
462 ${LibMagicConfigureOptions}
463 make && make install${strip}
464 for file in ${FILE_LIST} ; do
465 if [ -f "${LibMagicInstallDir}"/lib/${file} ]; then
466 mv "${LibMagicInstallDir}"/lib/${file}\
467 "${LibMagicInstallDir}"/lib/${file}-${arch}
469 echo Cannot build and install LibMagic for ${arch}.
474 # -------------------------
475 # Create universal binaries
476 # -------------------------
477 for file in ${FILE_LIST} ; do
479 for arch in ${ARCH_LIST} ; do
480 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
483 cd "${LibMagicInstallDir}"
484 lipo -create ${OBJ_LIST} -o lib/${file}
485 # check for the "missing link"...
486 test -f lib/libmagic.dylib || (cd lib ; ln -s "${LibMagicLibrary}" libmagic.dylib)
492 for arch in ${ARCH_LIST} ; do
493 rm -f "${LibMagicInstallDir}"/lib/*-${arch}
497 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
498 # we have a private HunSpell source tree at hand...
499 # so let's build and install it
500 if [ -z "${HunSpellVersion}" ]; then
501 HunSpellVersion=$(grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
504 HunSpellName="Hunspell"
505 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
507 echo Build hunspell library ${HunSpellBase}
508 echo configure options:
509 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
511 mkdir -p "${HunSpellBuildDir}" && cd "${HunSpellBuildDir}"
513 # ----------------------------------------
514 # Build HunSpell for different architectures
515 # ----------------------------------------
516 FILE_LIST="${HunSpellLibrary}"
518 for arch in ${ARCH_LIST} ; do
520 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
521 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
522 "${HunSpellSourceDir}/configure"\
523 --prefix="${HunSpellInstallDir}"\
524 ${HunspellConfigureOptions}
525 make && make install${strip}
526 for file in ${FILE_LIST} ; do
527 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
528 mv "${HunSpellInstallDir}"/lib/${file}\
529 "${HunSpellInstallDir}"/lib/${file}-${arch}
531 echo Cannot build and install HunSpell for ${arch}.
536 # -------------------------
537 # Create universal binaries
538 # -------------------------
539 for file in ${FILE_LIST} ; do
541 for arch in ${ARCH_LIST} ; do
542 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
545 cd "${HunSpellInstallDir}"
546 lipo -create ${OBJ_LIST} -o lib/${file}
547 # check for the "missing link"...
548 test -f lib/libhunspell.dylib || (cd lib ; ln -s "${HunSpellLibrary}" libhunspell.dylib)
554 for arch in ${ARCH_LIST} ; do
555 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
559 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
560 # we have a private ASpell source tree at hand...
561 # so let's build and install it
562 if [ -z "${ASpellVersion}" ]; then
563 ASpellVersion=$(grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()")
567 ASpellBase="${ASpellName}-${ASpellVersion}"
569 echo Build aspell library ${ASpellBase}
570 echo configure options:
571 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
573 # ASpell builds inplace only :(
574 cd "${ASpellSourceDir}"
576 # ----------------------------------------
577 # Build ASpell for different architectures
578 # ----------------------------------------
579 FILE_LIST="${ASpellLibrary}"
581 for arch in ${ARCH_LIST} ; do
583 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
584 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
585 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
586 --prefix="${ASpellInstallDir}"\
587 ${AspellConfigureOptions}
588 make && make install${aspellstrip}
589 for file in ${FILE_LIST} ; do
590 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
591 mv "${ASpellInstallDir}"/lib/${file}\
592 "${ASpellInstallDir}"/lib/${file}-${arch}
594 echo Cannot build and install ASpell for ${arch}.
599 # -------------------------
600 # Create universal binaries
601 # -------------------------
602 for file in ${FILE_LIST} ; do
604 for arch in ${ARCH_LIST} ; do
605 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
608 cd "${ASpellInstallDir}"
609 lipo -create ${OBJ_LIST} -o lib/${file}
615 for arch in ${ARCH_LIST} ; do
616 rm -f "${ASpellInstallDir}"/lib/*-${arch}
622 echo "Frameworks/${1}.framework"
625 LYX_FILE_LIST="lyx lyxclient tex2lyx"
626 BUNDLE_PATH="Contents/MacOS"
627 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
630 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
631 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
633 case "${EnableCXX11}" in
636 export CXX="c++ -stdlib=libc++"
637 export CXXFLAGS=-std=c++11
641 # -------------------------------------
642 # Automate configure check
643 # -------------------------------------
644 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
645 ( cd "${LyxSourceDir}" && sh autogen.sh )
647 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
648 dname=$(dirname "$file")
649 if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
650 ( cd "${LyxSourceDir}" && sh autogen.sh )
655 # -------------------------------------
656 # Build LyX for different architectures
657 # -------------------------------------
659 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
660 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
661 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
664 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
665 HunSpellFramework=$(framework_name Hunspell)
666 HunSpellFramework=$(basename "${HunSpellFramework}")
667 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
668 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
669 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
671 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
672 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
674 for arch in ${ARCH_LIST} ; do
676 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
677 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
679 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
680 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
682 if [ "$configure_qt_frameworks" = "yes" ]; then
683 export QT_CORE_CFLAGS="-FQtCore"
684 export QT_CORE_LIBS="-framework QtCore"
685 export QT_FRONTEND_CFLAGS="-FQtGui"
686 export QT_FRONTEND_LIBS="-framework QtGui"
687 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
688 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
691 echo LDFLAGS="${LDFLAGS}"
693 echo CPPFLAGS="${CPPFLAGS}"
695 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"}
696 "${LyxSourceDir}/configure"\
697 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
698 ${QtInstallDir:+"--with-qt-dir=${QtInstallDir}"} \
699 ${LyXConfigureOptions}\
700 --enable-build-type=rel && \
701 make ${MAKEJOBS} && make install${strip}
702 for file in ${LYX_FILE_LIST} ; do
703 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
704 mv "${LYX_BUNDLE_PATH}/${file}"\
705 "${LYX_BUNDLE_PATH}/${file}-${arch}"
707 echo ERROR: Cannot build and install LyX for ${arch}.
714 content_directory() {
716 content=$(dirname "${target}")
717 content=$(dirname "${content}")
722 echo install_name_tool "$@"
723 install_name_tool "$@"
726 private_framework() {
727 fwdir=$(framework_name "$1")
730 condir=$(content_directory "${target}")
731 libnm=$(basename "${source}")
732 mkdir -p "${condir}/${fwdir}"
733 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
734 cp -p "${source}" "${condir}/${fwdir}"
735 installname -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
737 installname -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
741 source="${QtInstallDir}"
743 version="Versions/${QtFrameworkVersion}/"
744 condir=$(content_directory "${target}")
745 mkdir -p "${condir}/Resources"
746 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
749 Translations = translations
751 if [ ! -d "${condir}/PlugIns" ]; then
752 mkdir -p "${condir}/PlugIns"
753 find "${source}/plugins" -name \*.dylib -print | grep -v _debug.dylib | while read libname ; do
754 echo Copy plugin "${libname}"
755 dylib=$(basename "${libname}")
756 dirname=$(dirname "${libname}")
757 dirname=$(basename "${dirname}")
758 mkdir -p "${condir}/PlugIns/${dirname}"
759 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
762 for libnm in ${QtLibraries} ; do
763 fwdir=$(framework_name "$libnm")
764 dirname=$(dirname "${fwdir}")
765 mkdir -p "${condir}/${dirname}"
766 dirname=$(basename "${fwdir}")
767 test -d "${condir}/${fwdir}" || (
768 echo Copy framework "${source}/lib/"$(basename "${fwdir}")
769 cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}"
770 rm -f "${condir}/${fwdir}/${version}${libnm}"_debug
771 installname -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
772 find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
773 if [ "${filename}" != "${target}" ]; then
774 otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
775 # pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
777 *@rpath/*"${libnm}"*"("*version*")"*)
778 echo rpath based name for ${libnm} is ok.
780 *"${libnm}"*"("*version*")"*)
782 "${source}/lib/${dirname}/${version}${libnm}"\
783 "@executable_path/../${fwdir}/${version}${libnm}"\
792 "${source}/lib/${dirname}/${version}${libnm}"\
793 "@executable_path/../${fwdir}/${version}${libnm}"\
796 if [ -d "${source}"/translations ]; then
797 if [ ! -d "${condir}/translations" ]; then
798 mkdir -p "${condir}/translations"
800 echo Copy Qt translations to "${condir}/translations"
801 cp -p "${source}"/translations/qt_*.qm "${condir}/translations"
805 # -------------------------
806 # Create universal binaries
807 # -------------------------
808 convert_universal() {
810 for file in ${LYX_FILE_LIST} ; do
812 for arch in ${ARCH_LIST} ; do
813 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
814 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
817 if [ -n "${OBJ_LIST}" ]; then
818 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
820 if [ -f "${LibMagicInstallDir}/lib/${LibMagicLibrary}" -a "yes" = "${libmagic_deployment}" ]; then
821 private_framework LibMagic "${LibMagicInstallDir}/lib/${LibMagicLibrary}" "${LYX_BUNDLE_PATH}/${file}"
823 if [ -f "${ASpellInstallDir}/lib/${ASpellLibrary}" -a "yes" = "${aspell_deployment}" ]; then
824 private_framework Aspell "${ASpellInstallDir}/lib/${ASpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
826 if [ -f "${HunSpellInstallDir}/lib/${HunSpellLibrary}" -a "yes" = "${hunspell_deployment}" ]; then
827 private_framework Hunspell "${HunSpellInstallDir}/lib/${HunSpellLibrary}" "${LYX_BUNDLE_PATH}/${file}"
829 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
830 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
832 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
833 case "${reference}" in
834 *"${LyxBuildDir}"*"("*")")
835 echo ERROR: Bad reference to "${reference}" found!!
840 for arch in ${ARCH_LIST} ; do
841 rm -f ${BUNDLE_PATH}/*-${arch}
846 find "$@" -type f -print | while read file ; do
847 echo $(md5 -q "$file") "$file"
848 done | sort | while read hash file ; do
849 ppath=$(dirname "$pfile")
850 path=$(dirname "$file")
851 if [ "$phash" = "$hash" -a "$ppath" = "$path" ]; then
852 pname=$(basename "$pfile")
853 name=$(basename "$file")
854 cmp -s "$pfile" "$file" && (
856 cd "$path" && ln -s "$pname" "$name" && echo link for "$file" created
864 copy_dictionaries() {
865 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
866 ASpellResources="${LyxAppPrefix}/Contents/Resources"
867 # try to reuse macports dictionaries for now
868 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
869 mkdir -p "${ASpellResources}"
870 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
871 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
872 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
873 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
875 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
876 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
877 if [ -d "${DictionarySourceDir}" ]; then
878 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
879 deduplicate "${HunSpellResources}"/dicts
882 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
883 MyThesResources="${LyxAppPrefix}/Contents/Resources"
884 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
885 deduplicate "${MyThesResources}"/thes
889 set_bundle_display_options() {
892 Y_POSITION=$((Y_BOUNDS - 65))
893 Y_BOUNDS=$((Y_BOUNDS + 20))
894 LYX_X_POSITION=$((X_BOUNDS / 4))
895 LYX_Y_POSITION=$Y_POSITION
896 APP_X_POSITION=$((3 * X_BOUNDS / 4))
897 APP_Y_POSITION=$Y_POSITION
898 WITH_DOCUMENTS=$(test -d "${1}/Documents" && echo true || echo false)
900 tell application "Finder"
901 set f to POSIX file ("${1}" as string) as alias
904 tell container window
905 set toolbar visible to false
906 set statusbar visible to false
907 set current view to icon view
909 set the bounds to {20, 50, $X_BOUNDS, $Y_BOUNDS}
912 set icon size of the icon view options of container window to 64
913 set arrangement of the icon view options of container window to not arranged
914 if ${WITH_DOCUMENTS} then
915 set position of item "Documents" to {$LYX_X_POSITION,0}
917 set position of item "${LyxName}.app" to {$LYX_X_POSITION,$LYX_Y_POSITION}
918 set position of item "Applications" to {$APP_X_POSITION,$APP_Y_POSITION}
919 set background picture of the icon view options\
920 of container window to file "background.png" of folder "Pictures"
921 set the bounds of the container window to {0, 0, $X_BOUNDS, $Y_BOUNDS}
922 update without registering applications
934 BGSIZE=$(file "$DmgBackground" | awk -F , '/PNG/{print $2 }' | tr x ' ')
935 BG_W=$(echo ${BGSIZE} | awk '{print $1 }')
936 BG_H=$(echo ${BGSIZE} | awk '{print $2 }')
938 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
940 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
941 # Unmount currently mounted disk image
942 mount | grep "${LyxBase}" && umount /Volumes/"${LyxBase}"
943 test -d /Volumes/"${LyxBase}" && rmdir /Volumes/"${LyxBase}"
945 # Mount the disk image
946 hdiutil attach "${DMGNAME}.sparseimage"
948 # Obtain device information
949 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
950 DEV=$(echo $DEVS | cut -f 1 -d ' ')
951 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
953 # copy in the application bundle
954 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
956 # copy in background image
957 mkdir -p "${VOLUME}/Pictures"
958 cp "${DmgBackground}" "${VOLUME}/Pictures/background.png"
959 # symlink applications
960 ln -s /Applications/ "${VOLUME}"/Applications
961 test -d "${DocumentationDir}" && cp -r "${DocumentationDir}" "${VOLUME}"
962 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H}
963 ${XCODE_DEVELOPER}/Tools/SetFile -a C "${VOLUME}"
964 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
966 # Unmount the disk image
967 hdiutil detach ${DEV}
969 # Convert the disk image to read-only
970 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
971 rm -f "${DMGNAME}.sparseimage"
974 # ------------------------------
975 # Building distribution packages
976 # ------------------------------
979 test -n "${LyxAppZip}" && (
980 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
984 for arch in ${ARCH_LIST} ; do
985 DMGARCH="${DMGARCH}-${arch}"
987 QtDmgArchSuffix=${QtMajorVersion}${DMGARCH}${QtAPI}.dmg
989 test -n "${DMGLocation}" && (
990 make_dmg "${DMGLocation}"
991 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt_deployment}" ]; then
992 rm -f "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
993 echo move to "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
994 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+${QtDmgArchSuffix}"
999 # ------------------------------
1001 # ------------------------------
1003 if [ ${LyxOnlyPackage:-"no"} = "no" ]; then