| 1 | Grand Central Dispatch (GCD) |
| 2 | |
| 3 | GCD is a concurrent programming framework first shipped with Mac OS X Snow |
| 4 | Leopard. This package is an open source bundling of libdispatch, the core |
| 5 | user space library implementing GCD. At the time of writing, support for |
| 6 | the BSD kqueue API, and specifically extensions introduced in Mac OS X Snow |
| 7 | Leopard and FreeBSD 9-CURRENT, are required to use libdispatch. Other |
| 8 | systems are currently unsupported. |
| 9 | |
| 10 | Configuring and installing libdispatch |
| 11 | |
| 12 | GCD is built using autoconf, automake, and libtool, and has a number of |
| 13 | compile-time configuration options that should be reviewed before starting. |
| 14 | An uncustomized install requires: |
| 15 | |
| 16 | sh autogen.sh |
| 17 | ./configure |
| 18 | make |
| 19 | make install |
| 20 | |
| 21 | The following configure options may be of general interest: |
| 22 | |
| 23 | --with-apple-libc-source |
| 24 | |
| 25 | Specify the path to Apple's Libc package, so that appropriate headers can |
| 26 | be found and used. |
| 27 | |
| 28 | --with-apple-libclosure-source |
| 29 | |
| 30 | Specify the path to Apple's Libclosure package, so that appropriate headers |
| 31 | can be found and used. |
| 32 | |
| 33 | --with-apple-xnu-source |
| 34 | |
| 35 | Specify the path to Apple's XNU package, so that appropriate headers can be |
| 36 | found and used. |
| 37 | |
| 38 | --with-blocks-runtime |
| 39 | |
| 40 | On systems where -fblocks is supported, specify an additional library path |
| 41 | in which libBlocksRuntime can be found. This is not required on Mac OS X, |
| 42 | where the Blocks runtime is included in libSystem, but is required on |
| 43 | FreeBSD. |
| 44 | |
| 45 | The following options are likely to only be useful when building libdispatch on |
| 46 | Mac OS X as a replacement for /usr/lib/system/libdispatch.dylib: |
| 47 | |
| 48 | --with-apple-objc4-source |
| 49 | |
| 50 | Specify the path to Apple's objc4 package, so that appropriate headers can |
| 51 | be found and used. |
| 52 | |
| 53 | --with-apple-libauto-source |
| 54 | |
| 55 | Specify the path to Apple's libauto package, so that appropriate headers |
| 56 | can be found and used. |
| 57 | |
| 58 | --disable-libdispatch-init-constructor |
| 59 | |
| 60 | Do not tag libdispatch's init routine as __constructor, in which case it |
| 61 | must be run manually before libdispatch routines can be called. This is the |
| 62 | default when building on Mac OS X. For /usr/lib/system/libdispatch.dylib |
| 63 | the init routine is called automatically during process start. |
| 64 | |
| 65 | --enable-apple-tsd-optimizations |
| 66 | |
| 67 | Use a non-portable allocation scheme for pthread per-thread data (TSD) keys |
| 68 | when building libdispatch for /usr/lib/system on Mac OS X. This should not |
| 69 | be used on other OS's, or on Mac OS X when building a stand-alone library. |
| 70 | |
| 71 | Typical configuration commands |
| 72 | |
| 73 | The following command lines create the configuration required to build |
| 74 | libdispatch for /usr/lib/system on OS X MountainLion: |
| 75 | |
| 76 | sh autogen.sh |
| 77 | cflags='-arch x86_64 -arch i386 -g -Os' |
| 78 | ./configure CFLAGS="$cflags" OBJCFLAGS="$cflags" CXXFLAGS="$cflags" \ |
| 79 | --prefix=/usr --libdir=/usr/lib/system \ |
| 80 | --disable-dependency-tracking --disable-static \ |
| 81 | --enable-apple-tsd-optimizations \ |
| 82 | --with-apple-libc-source=/path/to/10.8.0/Libc-825.24 \ |
| 83 | --with-apple-libclosure-source=/path/to/10.8.0/libclosure-59 \ |
| 84 | --with-apple-xnu-source=/path/to/10.8.0/xnu-2050.7.9 \ |
| 85 | --with-apple-objc4-source=/path/to/10.8.0/objc4-532 \ |
| 86 | --with-apple-libauto-source=/path/to/10.8.0/libauto-185.1 |
| 87 | make check |
| 88 | |
| 89 | Typical configuration line for FreeBSD 8.x and 9.x to build libdispatch with |
| 90 | clang and blocks support: |
| 91 | |
| 92 | sh autogen.sh |
| 93 | ./configure CC=clang --with-blocks-runtime=/usr/local/lib |
| 94 | make check |