4 | | * Adding the universal build flags (''-arch ppc -arch ppc64 ..'') to the compiler flags: Suited for straight compilation of executables |
5 | | * Adding universal build flags to the CFLAGS etc.: Suited for certain autotool driven builds |
| 4 | * 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: |
| 5 | {{{ |
| 6 | build.args-append CC="${configure.cc} [get_canonical_archflags cc]" |
| 7 | }}} |
| 8 | 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`. |
| 9 | * 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: |
| 10 | {{{ |
| 11 | configure.universal_cflags -isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc |
| 12 | configure.universal_cppflags -isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk |
| 13 | configure.universal_cxxflags -isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc |
| 14 | configure.universal_ldflags -Wl,-syslibroot,${developer_dir}/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc |
| 15 | }}} |
| 16 | On Tiger on Intel and on Leopard, they are: |
| 17 | {{{ |
| 18 | configure.universal_cflags -arch i386 -arch ppc |
| 19 | configure.universal_cxxflags -arch i386 -arch ppc |
| 20 | configure.universal_ldflags -arch i386 -arch ppc |
| 21 | }}} |
| 22 | On Snow Leopard and later, they are: |
| 23 | {{{ |
| 24 | configure.universal_cflags -arch x86_64 -arch i386 |
| 25 | configure.universal_cxxflags -arch x86_64 -arch i386 |
| 26 | configure.universal_ldflags -arch x86_64 -arch i386 |
| 27 | }}} |
| 28 | The exception is `configure.universal_args`, which has the same default across platforms: |
| 29 | {{{ |
| 30 | configure.universal_args --disable-dependency-tracking |
| 31 | }}} |
7 | | * Separating builds for different architectures, merging the different (single-arch) destroots: See the muniversal portgroup (emulation or multiple build machines differing in arch may be necessary for some ports) |
8 | | |
| 33 | * 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: |
| 34 | - When the port tries to use the `--enable-dependency-tracking` configure flag anyways, which makes building normally result in an error like this: |
| 35 | {{{ |
| 36 | gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags |
| 37 | }}} |
| 38 | - When the build system tries to put a fat archive inside another archive, resulting in an error like this: |
| 39 | {{{ |
| 40 | /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) |
| 41 | }}} |
| 42 | (this works when the archive is '''not''' fat) |
| 43 | - When the build system has architecture-specific assembly, or otherwise builds files differently based on architecture. |