wiki:howto/buildUniversal

<- Back to the HOWTO section

How to build Universal Binaries

  • Audience: Users with both PowerPC- and Intel-based Macs who want to compile ports only once
  • Requires: MacPorts >=1.6.0

Introduction

Most ports in the MacPorts ports tree can use the +universal variant (even those that don't explicitly mention it), which enables compiling the binaries for both PowerPC and Intel architectures, or for i386 as well as x86_64, etc fat binaries. This means the resulting ports can be used on both Intel-based and PowerPC-based Macs, etc. This HOWTO shows how to compile ports with the +universal variant. It also gives some indications as to how to use these ports on different machines, so as to compile ports only once, on the fastest of two machines, for instance.

The +universal variant

MacPorts, by default, builds ports that work only on the current local architecture. Building with the +universal variant changes this to always include both Intel and PowerPC code, regardless of whether you're currently on an Intel or PowerPC Mac. Building a port with the +universal variant is simple. Just specify it when installing the port:

port install portname +universal

as you would for other variants.

Using the same ports on two machines

Building all ports universal : edit variants.conf

You can add +universal to your /opt/local/etc/macports/variants.conf to ask MacPorts to build all ports you install with that variant, without having to remember to type it at every install command. However, some ports have not yet been tested as universal binaries and may not build properly. Or they may build but then not work on the foreign architecture. For some ports the universal variant has been expressly disabled, either because no way has been found to make it possible, or because nobody has yet tried to make it possible. If you encounter such a port, you can search the Trac tickets and the mailing lists to see if this is already being addressed. If not, you can file a ticket.

You can also edit your macports.conf file to specify which architectures a "universal" build targets, for instance, i386 and ppc64, etc.

Using the ports on two different Macs

Using the +universal variant is mainly useful if you intend to compile the ports on one machine and use them on another, for instance if you want to avoid hogging your main machine, or have a fast machine and a slow one. If you want to use the ports from one computer on another, it's best to transfer the entire MacPorts installation from the Mac that compiles the ports to the other Mac. That is, take all of /opt/local on the Mac in charge of building ports, and copy it to the other using rsync or as a tarball. You might exclude the /opt/local/var/macports/distfiles directory to save space if desired.

It is not recommended to attempt to build a port with the +universal on the first Mac and then copy just that port's files to the other machine. For one thing the port may have dependencies on other ports. For another, MacPorts on the secondary machine wouldn't know that you had copied these items, port installed wouldn't show the port as installed, etc.

If you choose to use ports built on one Mac on another, both must have the same major version of Mac OS X installed, preferably the same version entirely, and should have the same version of Xcode too. For example both must be running Tiger with Xcode 2.5, or both must be running Leopard with Xcode 3.0. Don't attempt this if they're running different major versions.

Building MacPorts itself universally

MacPorts itself (i.e. the port command) is universal when installed from the MacPorts installation disk image. It is not universal after doing a port selfupdate, which means that rsyncing the entire /opt/local directory may present some problems when attempting to use the port command on the other mac.

Notes

The Building MacPorts itself universally section raises the problem of building MacPorts itself universally. Solutions to this problem are being discussed: http://lists.macosforge.org/pipermail/macports-users/2008-May/010287.html.

<- Back to the HOWTO section

Last modified 12 years ago Last modified on Apr 11, 2013, 2:43:16 PM