Changes between Version 1 and Version 2 of BuildMacApp
- Timestamp:
- Apr 2, 2008, 3:47:15 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BuildMacApp
v1 v2 11 11 12 12 Building 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 above14 * i686-apple-darwin 32-bit intel processors running OS 10.4.0 and above15 * x86_64-apple-darwin: 64-bit intel processors running OS 10.5.0 and above13 * 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 16 16 BOINC does not support 64-bit PowerPC applications for the Mac. 17 17 … … 19 19 20 20 Although 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. 23 23 24 24 The 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: 26 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 27 * An Intel development system running OS 10.4.x 28 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.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 30 31 31 You 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. … … 117 117 * On any other Intel Mac, it runs the i386 executable. 118 118 119 == Build Any Other Needed Libraries == 119 120 120 **** Build Any Other Needed Libraries **** 121 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. 121 122 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 == 126 124 127 125 We 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 126 127 {{{ 129 128 cd {path}/BOINC_dev/ 130 129 mkdir boinc_samples 131 130 cd boinc_samples/ 132 131 svn co http://boinc.berkeley.edu/svn/trunk/boinc_samples 132 }}} 133 133 134 === Using an XCode Project === 134 135 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. 136 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'''. 138 137 139 138 Use the example XCode project as a guide or a starting point to create an XCode project for your own application. 140 139 141 **** Using a Generic Makefile With a Custom Shell Script **** 140 === Using a Generic Makefile With a Custom Shell Script === 142 141 143 142 Type the following in Terminal: 144 143 144 {{{ 145 145 cd {path}/BOINC_dev/boinc_samples/example_app/Mac/ 146 146 sh MakeMacExample.sh -clean 147 }}} 147 148 148 149 Again, you can use this shell script as a guide or starting point to create one for your application. Let's examine the details: 149 150 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.151 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. 151 152 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/. 153 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 `{path}/BOINC_dev/boinc/mac_build/`. 154 154 155 155 Here are the elements of our script: 156 156 157 {{{ 157 158 export 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 }}} 160 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 161 162 {{{ 160 163 export MACOSX_DEPLOYMENT_TARGET=10.3 164 }}} 161 165 Specifies 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 166 167 {{{ 163 168 export CC=/usr/bin/gcc-3.3;export CXX=/usr/bin/g++-3.3 164 Specify the compiler to use 169 }}} 170 Specifies which compiler to use. 165 171 172 {{{ 166 173 export 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 }}} 175 Specifies the appropriate SDK for the minimum target OS X version and the architecture for the linker. 168 176 177 {{{ 169 178 export 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 }}} 180 Specifies the appropriate SDK for the minimum target OS X version and the architecture for the compiler. For an explanation of _NONSTD_SOURCE, see: 171 181 http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/compat.5.html 172 182 173 **** Using a Custom Makefile **** 183 === Using a Custom Makefile === 174 184 175 185 Type the following in Terminal: 176 186 187 {{{ 177 188 cd {path}/BOINC_dev/boinc_samples/example_app/ 178 189 Make -f MakeMacExample.sh clean all 190 ))) 179 191 180 The elements of our custom Makefile correspond to those described in our script, except that we include in the CXXFLAGSeither181 -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.192 The 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`. 182 194 183 195