#!/bin/bash # # Set this script executable (chmod +x build_all_cairo) and # run it (./build_all_cairo). # # It will produce BuildCairo/ folder, with Resources/ and Include/. # # david van brink 2011.12.27 # # Adapted from http://cairographics.org/end_to_end_build_for_mac_os_x/ # # Initial Setup # # Changes from Travis Griggs' original instructions: # # 1. Put it in ./ instead of ../Frameworks/. # This gave me more flexibility for deploying next to # plain old binaries, &c. More DLL's of olden times. # # 2. Cairo 1.10.2 fixes a Mac OS X bug where harmless but # unsightly error messages are emitted in some cases, # if you're doing headless work I think. (Also bump # to pixman 0.24.0.) # # 3. Use @loader_path instead of @executable_path, so my plugin # code can refer to cairo in its local bundle... and # I use it as ./dylib, rather than ../Frameworks/dylib # # To use: # 1. Run this script, which produces BuildCairo folder. # 2. Add BuildCairo/include/ to your search path # (In XCode Build Settings, be sure to "Show All" settings, # search for Path, and enable "Always Search User Paths".) # 3. Add the files in BuildCairo/Resources (1 by 1, not the folder) # (These are added to Build Phases "Link Binary With Library" and # also to "Copy Bundle Resources".) # # +------------------------ # | Clean output directory export BuildDir=`pwd`/BuildCairo rm -rf ${BuildDir} mkdir ${BuildDir} cd ${BuildDir} # +------------------------ # | Fetch the components, renamed without version numbers curl http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz -o pkgconfig.tgz curl ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.46.tar.gz -o libpng.tgz #curl http://www.cairographics.org/releases/pixman-0.16.2.tar.gz -o pixman.tgz curl http://www.cairographics.org/releases/pixman-0.24.0.tar.gz -o pixman.tgz #curl http://www.cairographics.org/releases/cairo-1.8.8.tar.gz -o cairo.tgz #curl http://www.cairographics.org/releases/cairo-1.8.10.tar.gz -o cairo.tgz curl http://www.cairographics.org/releases/cairo-1.10.2.tar.gz -o cairo.tgz # | dvb11: 1.10 is later, but I could NOT get its ./configure to work. :( # | the "2" means for python 2.x curl http://cairographics.org/releases/py2cairo-1.8.10.tar.gz -o py2cairo.tgz # +------------------------ # | Expand the tarballs tar -xzf pkgconfig.tgz tar -xzf libpng.tgz tar -xzf pixman.tgz tar -xzf cairo.tgz tar -xzf py2cairo.tgz # +------------------------ # | And again, rename the result folders without version numbers mv pkg-config-* pkgconfig mv libpng-* libpng mv pixman-* pixman mv cairo-* cairo mv py*cairo-* py2cairo # +------------------------ # | Build Pkg-config cd ${BuildDir}/pkgconfig ./configure --prefix=${BuildDir} make make install # | And use this local version from here out export PKG_CONFIG=${BuildDir}/bin/pkg-config export PKG_CONFIG_PATH=${BuildDir}/lib/pkgconfig # +------------------------ # | Environment for which targets, SDK, &c # | (I'm doing only 64-bit, 10.6 and later.) export MACOSX_DEPLOYMENT_TARGET=10.6 export CC="gcc-4.2" export LDFLAGS="-arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk" export CFLAGS="-Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk" # +------------------------ # | Build libpng cd ${BuildDir}/libpng ./configure --prefix=${BuildDir} --disable-dependency-tracking make make install # +------------------------ # | Build pixman cd ${BuildDir}/pixman ./configure --prefix=${BuildDir} --disable-dependency-tracking make make install # +------------------------ # | Build cairo cd ${BuildDir}/cairo ./configure --prefix=${BuildDir} --disable-xlib --disable-ft --disable-dependency-tracking make make install # +------------------------ # | Build py cairo cd ${BuildDir}/py2cairo ./configure --prefix=${BuildDir} make make install # +------------------------------ # | Gather the dylibs # | # | NOTE! Travis Griggs (travisgriggs@gmail.com)'s instructions put them # | in a folder called "Frameworks". I'm keeping them local, # | so they need to be *next to* whoever uses them. DYLIBS=${BuildDir}/Dylibs mkdir ${DYLIBS} cd ${DYLIBS} cp ${BuildDir}/lib/libpng12.0.dylib . cp ${BuildDir}/lib/libpixman-1.0.dylib . cp ${BuildDir}/lib/libcairo.2.dylib . # +------------------------ # | fix paths... # | # | Here is the mysterious magic that lets the libraries be # | transported with your app bundle. I think it tells the # | libraries where to consider themselves, and where to # | consider their inter-library dependencies... install_name_tool -id @loader_path/libpng12.0.dylib libpng12.0.dylib install_name_tool -id @loader_path/libpixman-1.0.dylib libpixman-1.0.dylib install_name_tool -id @loader_path/libcairo.2.dylib libcairo.2.dylib install_name_tool -change ${BuildDir}/lib/libpixman-1.0.dylib @loader_path/libpixman-1.0.dylib libcairo.2.dylib install_name_tool -change ${BuildDir}/lib/libpng12.0.dylib @loader_path/libpng12.0.dylib libcairo.2.dylib # | Fix up pycairo to point locally, too. PYCAIRO=${BuildDir}/lib/python2.6/site-packages/cairo cd ${PYCAIRO} install_name_tool -change ${BuildDir}/lib/libpixman-1.0.dylib @loader_path/libpixman-1.0.dylib _cairo.so install_name_tool -change ${BuildDir}/lib/libpng12.0.dylib @loader_path/libpng12.0.dylib _cairo.so install_name_tool -change ${BuildDir}/lib/libcairo.2.dylib @loader_path/libcairo.2.dylib _cairo.so # | And make copies of the libraries right here, for pycairo direct install, too. cp ${DYLIBS}/libpng12.0.dylib . cp ${DYLIBS}/libpixman-1.0.dylib . cp ${DYLIBS}/libcairo.2.dylib . echo . echo . Done Building echo . Find the dynamic libraries in ${DYLIBS} echo . Find the Python Cairo library in ${PYCAIRO} # Done!