Changes between Initial Version and Version 1 of BuildMacApp


Ignore:
Timestamp:
Apr 2, 2008, 3:37:03 AM (16 years ago)
Author:
charlief
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildMacApp

    v1 v1  
     1= Building BOINC Project Applications for Macintosh OS X =
     2'''Last updated 4/2/08'''
     3
     4This document applies to BOINC libraries 6.1.12 and later.
     5
     6Contents of this document:
     7
     8[[PageOutline(1-10,,inline)]]
     9
     10== General Considerations ==
     11
     12Building applications for Macintosh OS X is complicated by the fact that Mac OS X is actually 3 different platforms:
     13* powerpc-apple-darwin: PowerPC processors running OS 10.3.0 and above
     14* i686-apple-darwin 32-bit intel processors running OS 10.4.0 and above
     15* x86_64-apple-darwin: 64-bit intel processors running OS 10.5.0 and above
     16BOINC does not support 64-bit PowerPC applications for the Mac.
     17
     18Of course, you can choose to support only some of these platforms.  For example, you may not need a 64-bit version.  If your project does not support the x86_64-apple-darwin platform, BOINC will automatically request your i686-apple-darwin application.  And /or you may choose not to support the powerpc-apple-darwin platform.
     19
     20Although BOINC version 6.1.0 supports only Mac OS X 10.3.9 and later, earlier versions supported all versions back to OS 10.3.0.  The GCC compiler version 4.0 was introduced in OS 10.3.9.  OS 10.3.0 through 10.3.8 can't run applications built with GCC 4.0, so you have 2 choices if you want to support PowerPC (G3, G4 and G5) processors:
     21* Build  your PowerPC application with GCC 4.0 and only distribute your application to Macs running 10.3.9 or later.
     22* Build your PowerPC application with GCC 3.3.
     23
     24The libraries supplied with different versions of OS X support different APIs.  You need to take certain steps to ensure that you use only APIs that are available in all the OS versions you plan to support.  There are two basic ways to accomplish this:
     25* Build each platform on a system running the oldest OS you need to support:
     26    * 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)
     27    * An Intel development system running OS 10.4.x
     28    * 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.)
     29* 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.
     30
     31You will also need to build the BOINC libraries on each platform and any other libraries your application needs.  You can use the Makefiles supplied in the BOINC CVS tree to build the BOINC libraries with this approach, or build them as Universal Binaries using the BOINC XCode project, as described later in this document.
     32
     33At the time this is written, the BOINC Makefiles do not build 64-bit binaries.
     34
     35== Cross-Platform Development ==
     36
     37Apple provides the tools necessary to cross-compile for all three BOINC Mac platform on any Mac running OS 10.5.x.  If you don't need to support the x86_64-apple-darwin platform, you can also cross-compile on OS 10.4.x.
     38
     39Apple 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.
     40
     41You 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".
     42
     43Be sure to select a custom install and get the OS 10.3.9 SDK if you want to support the powerpc-apple-darwin platform.
     44
     45Otherwise, 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:
     46http://connect.apple.com
     47
     48The example_app found in boinc_samples has examples of 3 different ways to build the application for all 3 platforms using cross-development:
     49* Create an XCode project
     50* Use a generic Makefile with a custom shell script
     51* Use a custom Makefile
     52
     53The basic requirements for building each platform are:
     54* Specify the architecture: ppc, i386 or x86_64
     55* Specify the compiler to use if it is GCC-3.3.
     56* Specify the appropriate SDK for the minimum target OS X version.
     57* Specify the Mac OSX Deployment Target, which is the minimum target OS X version.  This tells the compiler to reject any attempts to use APIs not available in that version of OS X.
     58
     59== Preparing To Build ==
     60
     61Create a parent directory within which to work.  In this description , we will call it BOINC_dev, but you can name it anything you wish.  This parent directory will contain the BOINC source files, your application project, and any other library projects you will use. 
     62
     63Get the BOINC source tree from SVN, and put it in the same BOINC_dev folder. To do this, type the following in Terminal:
     64{{{
     65cd {path}/BOINC_dev/
     66svn co http://boinc.berkeley.edu/svn/trunk/boinc
     67}}}
     68      (You may change the name of the boinc directory to anything you wish.)
     69
     70The command above retrieves the source code from the HEAD or development branch of the SVN repository. See more information on [SourceCode getting the BOINC source code].
     71
     72Build the BOINC libraries as follows:
     73
     74Build BOINC as follows:
     75
     76BOINC itself is built using the '''boinc.xcodeproj''' file.  You can either build directly in XCode (more information below) or run the '''BuildMacBOINC.sh''' script:
     77
     78{{{
     79cd {path}/BOINC_dev/boinc/mac_build/
     80source BuildMacBOINC.sh -clean -lib
     81}}}
     82
     83The complete syntax for this script is
     84
     85{{{
     86source BuildMacBOINC.sh [-dev] [-noclean] [-no64bit] [-all] [-lib] [-client] [-help]
     87}}}
     88
     89The options for BuildMacBOINC.sh are:
     90
     91      -dev::
     92          build the development (debug) version (native architecture only). default is deployment (release) version (universal binaries: ppc, i386 and x86_64).
     93      -noclean::
     94          don't do a 'clean' of each target before building. default is to clean all first.
     95        -no64bit::
     96          build 32-bit binaries only, no x86_64 architecture.
     97
     98The following arguments determine which targets to build
     99
     100      -all::
     101          build all targets (i.e. target 'Build_All' -- this is the default)
     102      -lib::
     103          build the three libraries: libboinc_api.a, libboinc_graphics_api.a, libboinc.a
     104      -client::
     105          build two targets: BOINC client and command-line utility [BoincCmd boinc_cmd] (also builds libboinc.a, since boinc_cmd requires it.)
     106
     107Both -lib and -client may be specified to build five targets (no BOINC Manager.)
     108
     109Note: You may find three XCode projects in the BOINC_dev/boinc/mac_build/ directory:
     110    * '''boinc.pbproj''' is obsolete and should no longer be used.
     111    * '''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.
     112    * '''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.
     113
     114The 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:
     115 * On a PowerPC Mac, it runs the ppc executable.
     116 * On a Mac with a 64-bit Intel processor running OS 10.5 or later, it runs the x86_64 executable.
     117 * On any other Intel Mac, it runs the i386 executable.
     118
     119
     120**** Build Any Other Needed Libraries ****
     121
     122If you are building a third-party library (such as JPEG), you will need to take the steps listed above in the section Cross-Platform Development.  See the files boinc_samples/example_app/Makefile_mac2 and boinc_samples/example_app/MakeMacExample.sh for examples of how to accomplish this.
     123
     124
     125**** Build Your Application ****
     126
     127We will use the example_app to illustrate the 3 methods of cross-compiling.   Download this sample project from Subversion, and put it in the same BOINC_dev folder.  To do this, type the following in Terminal:
     128
     129cd {path}/BOINC_dev/
     130mkdir boinc_samples
     131cd boinc_samples/
     132svn co http://boinc.berkeley.edu/svn/trunk/boinc_samples 
     133
     134
     135**** Using an XCode Project ****
     136
     137Double-click on the project file boinc_samples/mac_build/UpperCase2.xcodeproj.  At the top of the main window, select Build_All for the Active Target, and ppc_Deployment for the Active Build Configuration.  Then click on the Build icon (or select Build from the Build menu.)  Repeat for Active Build Configurations i386_Deployment and x86_64_Deployment.
     138
     139Use the example XCode project as a guide or a starting point to create an XCode project for your own application.
     140
     141**** Using a Generic Makefile With a Custom Shell Script ****
     142
     143Type the following in Terminal:
     144
     145cd {path}/BOINC_dev/boinc_samples/example_app/Mac/
     146sh MakeMacExample.sh -clean
     147
     148Again, you can use this shell script as a guide or starting point to create one for your application.  Let's examine the details:
     149
     150In this case, there is no autoconf file, so we had to modify the generic Makefile slightly.  The most significant change was to add the variable VARIANTFLAGS to the list of arguments in CFlags.  The remaining changes were to ensure that the search paths included the needed BOINC headers and  libraries.
     151
     152If your application uses an autoconf file, you can set the various environment variables for configure directly.  For examples, see the scripts buildc-ares.sh, buildcurl.sh and buildjpeg.sh in the directory
     153{path}/BOINC_dev/boinc/mac_build/.
     154
     155Here are the elements of our script:
     156
     157export PATH=/usr/local/bin:$PATH
     158XCode 2.4.1 installs autoconf 2.59 and automake 1.6.3.  If you installed a later version of either or both, they will be in the /usr/local/bin/ directory.  This line ensures that the system will look there first.
     159
     160export MACOSX_DEPLOYMENT_TARGET=10.3
     161Specifies the Mac OSX Deployment Target, which is the minimum target OS X version.  This tells the compiler to reject any attempts to use APIs not available in that version of OS X.
     162
     163export CC=/usr/bin/gcc-3.3;export CXX=/usr/bin/g++-3.3
     164Specify the compiler to use
     165
     166export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.3.9.sdk -arch ppc"
     167Specify the appropriate SDK for the minimum target OS X version and the architecture for the linker.
     168
     169export VARIANTFLAGS="-arch ppc -D_NONSTD_SOURCE -isystem /Developer/SDKs/MacOSX10.3.9.sdk"
     170Specify the appropriate SDK for the minimum target OS X version and the architecture for the compiler.  For an explanation of _NONSTD_SOURCE, see:
     171http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/compat.5.html
     172
     173**** Using a Custom Makefile ****
     174
     175Type the following in Terminal:
     176
     177cd {path}/BOINC_dev/boinc_samples/example_app/
     178Make -f MakeMacExample.sh clean all
     179
     180The elements of our custom Makefile correspond to those described in our script, except that we include in the CXXFLAGS either
     181-DMAC_OS_X_VERSION_MIN_REQUIRED=1030 (for GCC-3.3), or  either -mmacosx-version-min=10.4 or -mmacosx-version-min=10.5 (for GCC-4.0) instead of setting the environment variable MACOSX_DEPLOYMENT_TARGET.
     182
     183