wiki:MacBuild

Version 37 (modified by charlief, 17 years ago) (diff)

--

Building BOINC Clients and Applications on Macintosh OS X

Last updated 4/3/08

This document applies to BOINC version 6.1.0 and later. It has instructions for building the BOINC Client and Manager for Macintosh OSX. Information for building science project applications to run under BOINC on Macintosh OSX can be found here.

Note: the information in this document changes from time to time for different versions of BOINC. For any version of BOINC source files, the corresponding version of this document can be found in the source tree at:

boinc/mac_build/HowToBuildBOINC_XCode.rtf

Contents of this document:

  1. Building BOINC Clients and Applications on Macintosh OS X
    1. Important requirements for building BOINC software for the Mac
    2. Cross-Platform Development
    3. Building BOINC Manager with embedded Core Client plus libraries libboinc.a and libboinc_graphics_api.a
    4. Building BOINC Manager Installer
    5. Debugging and BOINC security

Important requirements for building BOINC software for the Mac

Building applications for Macintosh OS X is complicated by the fact that Mac OS X is actually 3 different platforms:

  • powerpc-apple-darwin: PowerPC processors running OS 10.3.0 and above
  • i686-apple-darwin: 32-bit intel processors running OS 10.4.0 and above
  • x86_64-apple-darwin: 64-bit intel processors running OS 10.5.0 and above

BOINC does not support 64-bit PowerPC applications for the Mac.

You need to take certain steps to ensure that you use only APIs that are available in all the OS versions BOINC supports for each architecture. There are two basic ways to accomplish this:

  • Build each platform on a system running the oldest OS you need to support, then combine them into a Universal Binary using the lipo command-line utility:
    • A PowerPC development system running OS 10.3.0 through 10.3.8 (or 10.3.9 if you won't support the older systems)
    • An Intel development system running OS 10.4.x
    • A 64-bit development Intel system running OS 10.5.x (The original Intel Macs used an Intel Core Duo processor which was 32-bit only. You must have an Intel Core 2 Duo or newer processor to run 64-bit applications.) However, at the time this is written, the BOINC Makefiles do not directly build 64-bit binaries
  • Use a single development system running OS 10.5.x and cross-compile for the various platforms. The remainder of this document describes that process.

The above requirements apply not only BOINC itself, but also the WxWidgets, JPEG, c-ares and cURL libraries, as well as all project applications. The BOINC Client does not use WxWidgets or JPEG, so only the c-ares and cURL libraries must be built for the x86_64 architecture.

Be sure to follow the directions in this document to ensure that these requirements are met.

BOINC version 6.1.0 supports only Mac OS X 10.3.9 and later; support for OS 10.3.0 through 10.3.8 has been discontinued. This allows us to build the BOINC Client and Manager using only GCC 4.0, which offers a number of advantages.

The BOINC Client includes support for the x86_64 (64-bit Intel) architecture beginning with version 6.1.0.

Cross-Platform Development

Apple provides the tools necessary to cross-compile for all three BOINC Mac platform on any Mac running OS 10.5.x.

Apple provides Software Developer Kits (SDKs) for OS 10.3.9, OS 10.4 and OS 10.5. These include all the header files and stub libraries appropriate to the corresponding versions of OS X.

You get these tools, including the GCC compilers and system library header files, by installing the XCode Tools package. I recommend running OS 10.5.x and installing XCode Tools 3.0 or later. If you have the OS 10.5 installation DVD for your system, you can install XCode Tools at the time you install the OS, or you can install it later by opening the file Optional Installs/XCode Tools/XCodeTools.mpkg.

Otherwise, you can download it from Apple's web site (it is large: 1.1 GB). You must be a member of the Apple Developer Connection to download the software, but you can join for free at: http://connect.apple.com

Building BOINC now requires XCode Tools version 2.4.1 or later; XCode 3.0 or later is recommended. Note that the MacOS10.3.9 SDK is not automatically included unless you customize the installation; click the Customize button in the Installation type step when you run the XCode Tools installer.

Source files are now archived using Subversion. You can download svnX, a free GUI application for running Subversion from either http://www.apple.com/downloads/macosx/development_tools/svnx.html or http://www.lachoseinteractive.net/en/community/subversion/svnx/.

You also need to install Subversion itself. One place to get it is: http://www.codingmonkeys.de/mbo/

Building BOINC Manager with embedded Core Client plus libraries libboinc.a and libboinc_graphics_api.a

BOINC depends on four third-party libraries: wxMac-2.8.7, c-ares-1.5.1, curl-7.18.0, and jpeg-6b. You can obtain these from the following URLs:

wxMac-2.8.7 (needed only if you are building the BOINC Manager):

http://www.wxwidgets.org

http://prdownloads.sourceforge.net/wxwindows/wxMac-2.8.7.tar.gz

http://downloads.sourceforge.net/wxwindows/wxMac-2.8.7.tar.bz2

curl-7.18.0:

http://curl.haxx.se

http://curl.haxx.se/download/curl-7.18.0.tar.gz

c-ares-1.5.1 (used by curl):

http://daniel.haxx.se/projects/c-ares/

http://daniel.haxx.se/projects/c-ares/c-ares-1.5.1.tar.gz

jpeg-6b (needed only if you are building the BOINC libboinc_graphics_api.a library):

http://www.ijg.org

ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

XCode 2.4.1 installs autoconf 2.59 and automake 1.6.3. XCode 3.0 installs autoconf 2.61 and automake 1.10. To determine the version number, type 'autoconf --version' or 'automake --version'. Building curl-7.18.0 requires autoconf 2.59 and automake 1.9.3 or later.

Upgrades for autoconf and automake are available from www.gnu.org:

http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz

http://ftp.gnu.org/gnu/automake/automake-1.10.tar.gz

XCode installed these utilities in the /usr/bin/ directory, but the upgrades by default will install in /usr/local/bin/. If you install there, you must also set your PATH environment variable to include that location. The scripts referenced below do this automatically.

All BOINC software for Power PC Macs must be built using MacOS10.3.9 SDK to assure backward compatibility with OS 10.3.9. All 32-bit BOINC software for Intel Macs must be built using GCC 4.0 and MacOS10.4.u SDK to allow cross-compiling. All 64-bit BOINC software for Intel Macs must be built using GCC 4.0 and MacOS10.5 SDK.

These are not done by either the XCode projects which come with wxMac-2.8.7, nor the AutoMake scripts supplied with wxMac-2.8.7, c-ares-1.5.1, curl-7.18.0, or jpeg-6b. So be sure to use our special scripts to build these packages.

Building BOINC and the library packages on which it depends requires OS 10.5 and XCode 2.4.1 (or greater).

  1. Create a parent directory within which to work. In this description , we will call it BOINC_dev, but you can name it anything you wish.
  2. Put the following 3 directories inside the BOINC_dev folder (omit any you don't need):
    c-ares-1.5.1
    curl-7.18.0
    jpeg-6b
    wxMac-2.8.7
    
    Important: do not change the names of any of these 3 directories.
  3. Get the BOINC source tree from SVN, and put it in the same BOINC_dev folder. To do this, type the following in Terminal:
    cd {path}/BOINC_dev/
    svn co http://boinc.berkeley.edu/svn/trunk/boinc
    
    (You may change the name of the boinc directory to anything you wish.)

The command above retrieves the source code from the HEAD or development branch of the SVN repository. See more information on getting the BOINC source code?.

  1. Run the script to build the c-ares, curl, jpeg and wxMac libraries as follows:
    cd {path}/BOINC_dev/boinc/mac_build/
    source setupForBoinc.sh -clean
    
    If you don't wish to force a full rebuild of everything, omit the -clean argument.

Note: this script builds c-ares and curl first, followed by jpeg and finally wxMac. If you haven't downloaded wxMac because you aren't building the BOINC Manager, the script will build c-ares, curl and jpeg. Likewise, if you downloaded only c-ares and curl because you need neither graphics nor the BOINC Manager, the script will build c-ares and curl before quitting.

  1. Build BOINC as follows:

BOINC itself is built using the boinc.xcodeproj file. You can either build directly in XCode (more information below) or run the BuildMacBOINC.sh script:

cd {path}/BOINC_dev/boinc/mac_build/
source BuildMacBOINC.sh

The complete syntax for this script is

source BuildMacBOINC.sh [-dev] [-noclean] [-no64bit] [-all] [-lib] [-client] [-help]

The options for BuildMacBOINC.sh are:

-dev
build the development (debug) version (native architecture only). default is deployment (release) version (universal binaries: ppc, i386 and x86_64).
-noclean
don't do a 'clean' of each target before building. default is to clean all first.
-no64bit
build 32-bit binaries only, no x86_64 architecture.

The following arguments determine which targets to build

-all
build all targets (i.e. target 'Build_All' -- this is the default)
-lib
build the three libraries: libboinc_api.a, libboinc_graphics_api.a, libboinc.a
-client
build two targets: BOINC client and command-line utility boinc_cmd? (also builds libboinc.a, since boinc_cmd requires it.)

Both -lib and -client may be specified to build five targets (no BOINC Manager.)

Note: You may find three XCode projects in the BOINC_dev/boinc/mac_build/ directory:

  • boinc.pbproj is obsolete and should no longer be used.
  • wxMac-BOINC.xcodeproj was needed for building older versions of the wxMac library in conjunction with the older versions of the setupForBoinc.sh or buildWxMac.sh scripts. It is not used for BOINC 5.9.2 or later.
  • boinc.xcodeproj builds BOINC. It can be used either with the BuildMacBOINC.sh script or as a stand-alone project. It has three extra build configurations, i386-Deployment and ppc-Deployment, which can be used for testing only to build for just one architecture, and Deployment-no64 which builds only 32-bit products. The Development build configuration builds only the native architecture and is used for debugging. The Deployment build configuration builds a universal binary and is suitable for release builds.

The standard release of BOINC version 6.1.0 and later contains a universal binary of the BOINC Client containing builds for three architectures: ppc, i386 and x86_64. The Mac OS automatically chooses the appropriate architecture as follows:

  • On a PowerPC Mac, it runs the ppc executable.
  • On a Mac with a 64-bit Intel processor running OS 10.5 or later, it runs the x86_64 executable.
  • On any other Intel Mac, it runs the i386 executable.

Building BOINC Manager Installer

To build the Installer for the BOINC Manager, you must be logged in as an administrator. If you are building BOINC version number x.y.z, type the following in Terminal, then enter your administrator password when prompted by the script:

cd {path}/BOINC_dev/boinc/
source {path}/BOINC_dev/boinc/mac_installer/release_boinc.sh x y z

Substitute the 3 parts of the BOINC version number for x y and z in the above. For example, to build the installer for BOINC version 5.5.4, the command would be

source {path}/BOINC_dev/boinc/mac_installer/release_boinc.sh 5 5 4

This will create a directory 'BOINC_Installer/New_Release_5_5_4' in the BOINC_dev directory.

To build version 5.5.4 of the Grid Republic flavor of BOINC, you would type:

cd {path}/BOINC_dev/boinc/
source {path}/BOINC_dev/boinc/mac_installer/release_GridRepublic.sh 5 5 4

This will create a directory 'BOINC_Installer/New_Release_GR_5_5_4' in the BOINC_dev directory.

Debugging and BOINC security

Version 5.5.4 of BOINC Manager for the Macintosh introduced new, stricter security measures. For details, please see the file Readme.rtf and web pages Sandbox Design and Sandbox User.

The GDB debugger can't attach to applications which are running as a different user or group so it ignores the S_ISUID and S_ISGID permission bits when launching an application. To work around this, BOINC does not use the special boinc_master or boinc_project users or groups when run from XCode.

The Development build only of the BOINC Manager allows you to change the ownership and permission settings of the BOINC Data and executables by entering an administrator user name and password. This also streamlines the development cycle by avoiding the need to run the installer for every change.

To restore the standard ownerships and permissions, run the installer.

For information on interpreting crash dumps and backtraces, see Mac Backtrace.