[cairo] Universal Framework for Mac OS X
Andreas Krinke
andreas.krinke at gmx.de
Mon Mar 23 15:35:56 PDT 2009
>> I will post the details of the framework creation if there is interest.
>
> Sure, please do so. We might find some helpful hints for the gtk-osx
> packages.
That's the way I did it:
At first, I installed the svn version of MacPorts using the howto at [1]
(after the heading "Making universal work for 10.4"). Maybe version
1.7.0 has full support for universal builds, so there might be no need
to use the svn version.
These are the steps:
$ svn co http://svn.macports.org/repository/macports/trunk/base MacPorts-svn
$ cd MacPorts-svn
$ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11/bin
$ sudo mkdir /Library/Tcl/macports-universal-10.4
$ ./configure --prefix=/opt/local-universal-10.4
--with-tclpackage=/Library/Tcl/macports-universal-10.4
--with-universal-target=10.4
--with-universal-sysroot=/Developer/SDKs/MacOSX10.4u.sdk
$ make
$ sudo make install
$ sudo vi /opt/local-universal-10.4/etc/macports/variants.conf
I this file, I added the line "+universal +no_x11 +quartz".
Later, this builds cairo without the x11 dependency and with quartz as
font backend.
$ sudo /opt/local-universal-10.4/bin/port sync
("sync", not "selfupdate", or you will get downgraded)
$ sudo vi /opt/local-universal-10.4/etc/macports/sources.conf
In this file I added file:///Users/ak/MacPorts/ports/ above the rsync
line. We can make copies of the PortFiles of libpixman, libpng and cairo
and change them there.
$ mkdir -p ~/MacPorts/ports/graphics
$ cp -R
/opt/local-universal-10.4/var/macports/sources/rsync.macports.org/release/ports/graphics/{libpixman
libpng cairo} ~/MacPorts/ports/graphics/
Then I changed the Portfiles of the three libraries to alter their
install_name. MacPorts sets it to the absolute path, but we need paths
relative to the executable inside the application bundle. The only way I
found to alter the path was to change the libtool script.
In cairo's Portfile (~/MacPorts/ports/graphics/cairo/Portfile) add the
following block:
post-configure {
reinplace "s|-install_name\\\\\$rpath/\\\\\$soname|-install_name
@executable_path/../Frameworks/Cairo.framework/Libraries/libcairo.2.dylib|g"
${worksrcpath}/../ppc/libtool
reinplace "s|-install_name\\\\\$rpath/\\\\\$soname|-install_name
@executable_path/../Frameworks/Cairo.framework/Libraries/libcairo.2.dylib|g"
${worksrcpath}/../i386/libtool
}
In libpixman's Portfile add:
post-configure {
reinplace "s|-install_name\\\\\$rpath/\\\\\$soname|-install_name
@executable_path/../Frameworks/Cairo.framework/Libraries/libpixman-1.0.14.0.dylib|g"
${worksrcpath}/../ppc/libtool
reinplace "s|-install_name\\\\\$rpath/\\\\\$soname|-install_name
@executable_path/../Frameworks/Cairo.framework/Libraries/libpixman-1.0.14.0.dylib|g"
${worksrcpath}/../i386/libtool
}
And in libpng's Portfile add:
post-configure {
reinplace "s|-install_name\\\\\$rpath/\\\\\$soname|-install_name
@executable_path/../Frameworks/Cairo.framework/Libraries/libpng12.0.dylib|g"
${worksrcpath}/libtool
}
Now it's time to update the portindex:
$ sudo /opt/local-universl-10.4/bin/portindex ~/MacPorts/ports
Install cairo and its dependencies via MacPorts:
$ sudo /opt/local-universl-10.4/bin/port install cairo
This should build libpixman, libpng and cairo.
All we have to do is to create the framework:
$ mkdir Cairo.framework
$ cd Cairo.framework
$ mkdir Headers
$ mkdir Libraries
$ mkdir Resources
Copy the libraries libcairo.2.dylib, libpixman-1.0.14.0.dylib and
libpng12.0.dylib from /opt/local-universal-10.4/lib/ to the Libraries
directory.
Copy all the header files to the Headers directory. The headers are
located at /opt/local-universal-10.4/include/cairo/ and .../pixman-1.
This is the list:
cairo-deprecated.h
cairo-features.h
cairo-pdf.h
cairo-ps.h
cairo-quartz.h
cairo-svg.h
cairo-versions.h
cairo.h
pixman-version.h
pixman.h
Then, I copied the Info.plist file from the cairo framework from the
gtk-osx project [2] to the Resources directory. Don't forget to change
the version numbers in the file.
Last but not least, create a symlink to the cairo library:
$ ln -s Libraries/libcairo.2.dylib Cairo
That's it. Now you should have an universal framework of cairo including
its dependencies.
Well, now I'm tired of typing :D
I know, this seems very complicated. I took ages to find all the little
pieces.
Don't forget the custom linker flags (see my original post) if you link
against the framework.
Andreas
[1] http://bamsoftware.com/wiki/Nmap/MacOSX
[2] http://gtk-osx.org/
More information about the cairo
mailing list