wiki:howto/buildUniversal

Version 2 (modified by alakazam@…, 17 years ago) (diff)

Add link to the current discussion regarding difficulties with building macports itself universally

<- Back to the HOWTO section

How to build Universal Binaries with +universal?

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

Introduction

Most ports in MacPorts ports tree can use the +universal variant, which enables compiling the binaries for both PowerPC and Intel architectures. This means the resulting ports can be used both on Intel based and PowerPC based machines. 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 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 macports' mailing lists for additional information.

Using the ports on two different macs

Using the +universal variant is mainly useful if you intend to compile the ports on one machine to 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 macports ports from one computer on another, it is 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 it as installed, etc.

If you choose to use ports built on one mac on another, bost 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 selfupdate, which means that rsyncing the entire /opt/local directory may present some problems when attempting to use the port command on the "mirror" mac.

Notes

The Building Macports 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