Changes between Version 1 and Version 2 of BuildMacApp


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

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildMacApp

    v1 v2  
    1111
    1212Building 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
     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
    1616BOINC does not support 64-bit PowerPC applications for the Mac.
    1717
     
    1919
    2020Although 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.
     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.
    2323
    2424The 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:
     25 * Build each platform on a system running the oldest OS you need to support:
    2626    * 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)
    2727    * An Intel development system running OS 10.4.x
    2828    * 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.
     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.
    3030
    3131You 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.
     
    117117 * On any other Intel Mac, it runs the i386 executable.
    118118
     119== Build Any Other Needed Libraries ==
    119120
    120 **** Build Any Other Needed Libraries ****
     121If 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.
    121122
    122 If 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 ****
     123== Build Your Application ==
    126124
    127125We 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:
    128126
     127{{{
    129128cd {path}/BOINC_dev/
    130129mkdir boinc_samples
    131130cd boinc_samples/
    132131svn co http://boinc.berkeley.edu/svn/trunk/boinc_samples 
     132}}}
    133133
     134=== Using an XCode Project ===
    134135
    135 **** Using an XCode Project ****
    136 
    137 Double-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.
     136Double-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'''.
    138137
    139138Use the example XCode project as a guide or a starting point to create an XCode project for your own application.
    140139
    141 **** Using a Generic Makefile With a Custom Shell Script ****
     140=== Using a Generic Makefile With a Custom Shell Script ===
    142141
    143142Type the following in Terminal:
    144143
     144{{{
    145145cd {path}/BOINC_dev/boinc_samples/example_app/Mac/
    146146sh MakeMacExample.sh -clean
     147}}}
    147148
    148149Again, you can use this shell script as a guide or starting point to create one for your application.  Let's examine the details:
    149150
    150 In 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.
     151In 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.
    151152
    152 If 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/.
     153If 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 `{path}/BOINC_dev/boinc/mac_build/`.
    154154
    155155Here are the elements of our script:
    156156
     157{{{
    157158export PATH=/usr/local/bin:$PATH
    158 XCode 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}}}
     160XCode 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.
    159161
     162{{{
    160163export MACOSX_DEPLOYMENT_TARGET=10.3
     164}}}
    161165Specifies 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.
    162166
     167{{{
    163168export CC=/usr/bin/gcc-3.3;export CXX=/usr/bin/g++-3.3
    164 Specify the compiler to use
     169}}}
     170Specifies which compiler to use.
    165171
     172{{{
    166173export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.3.9.sdk -arch ppc"
    167 Specify the appropriate SDK for the minimum target OS X version and the architecture for the linker.
     174}}}
     175Specifies the appropriate SDK for the minimum target OS X version and the architecture for the linker.
    168176
     177{{{
    169178export VARIANTFLAGS="-arch ppc -D_NONSTD_SOURCE -isystem /Developer/SDKs/MacOSX10.3.9.sdk"
    170 Specify the appropriate SDK for the minimum target OS X version and the architecture for the compiler.  For an explanation of _NONSTD_SOURCE, see:
     179}}}
     180Specifies the appropriate SDK for the minimum target OS X version and the architecture for the compiler.  For an explanation of _NONSTD_SOURCE, see:
    171181http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/compat.5.html
    172182
    173 **** Using a Custom Makefile ****
     183=== Using a Custom Makefile ===
    174184
    175185Type the following in Terminal:
    176186
     187{{{
    177188cd {path}/BOINC_dev/boinc_samples/example_app/
    178189Make -f MakeMacExample.sh clean all
     190)))
    179191
    180 The 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.
     192The elements of our custom Makefile correspond to those described in our script, except that we include in the `CXXFLAGS` either
     193`-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`.
    182194
    183195