Port(1) supports for universal builds is not good enough to handle non-trivial cases. We currently try to develop mechanisms to overcome this, so we can make more ports build universal more easily. === Approaches === * Adding the universal build flags ("-arch i386 -arch x86_64 ...") to the compiler flags (i.e. the "CC" environment variable itself): Suited for straight compilation of executables. This is usually done for hand-written Makefiles and often has to be done manually from the Portfile. For example, if the `build.cmd` is `make`, the code in the Portfile would look something like this: {{{ build.args-append CC="${configure.cc} [get_canonical_archflags cc]" }}} You could also try setting it in `build.env`, but sometimes `make` does not respect environment variables if that variable is not also used as a Makefile variable, so it is safer just to force it in `build.args`. * Adding universal build flags to the CFLAGS etc.: Suited for certain autotools-driven builds. This is done by default. The default values for these universal flags vary by platform. On Tiger on PowerPC, they are: {{{ configure.universal_cflags -isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc configure.universal_cppflags -isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk configure.universal_cxxflags -isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc configure.universal_ldflags -Wl,-syslibroot,${developer_dir}/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc }}} On Tiger on Intel and on Leopard, they are: {{{ configure.universal_cflags -arch i386 -arch ppc configure.universal_cxxflags -arch i386 -arch ppc configure.universal_ldflags -arch i386 -arch ppc }}} On Snow Leopard and later, they are: {{{ configure.universal_cflags -arch x86_64 -arch i386 configure.universal_cxxflags -arch x86_64 -arch i386 configure.universal_ldflags -arch x86_64 -arch i386 }}} The exception is `configure.universal_args`, which has the same default across platforms: {{{ configure.universal_args --disable-dependency-tracking }}} * Adding universal build flags to the libtool command e.g. `reinplace "s|CC -dynamiclib|CC -dynamiclib ${configure.universal_ldflags}|g" ${worksrcpath}/libtool` * Separating builds for different architectures, merging the different (single-arch) destroots: See the [browser:trunk/dports/_resources/port1.0/group/muniversal-1.0.tcl muniversal PortGroup] (emulation or multiple build machines differing in arch may be necessary for some ports). This is useful in various different situations: - When the port tries to use the `--enable-dependency-tracking` configure flag anyways, which makes building normally result in an error like this: {{{ gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags }}} - When the build system tries to put a fat archive inside another archive, resulting in an error like this: {{{ /opt/local/bin/ranlib: archive member: libtcs.a(libtddl.a) fat file for cputype (16777223) cpusubtype (3) is not an object file (bad magic number) }}} (this works when the archive is '''not''' fat) - When the build system has architecture-specific assembly, or otherwise builds files differently based on architecture. === Developers === [wiki:mww mww (Markus W. Weissmann)]