| 189 | == Removing -arch flags from *-config scripts and *.pc files == #archflags |
| 190 | |
| 191 | MacPorts provides `-arch` flags to ports' configure scripts in CFLAGS, LDFLAGS and similar variables, which tell the port what architecture(s) to build for, but these `-arch` flags should not appear in *-config scripts or pkg-config *.pc files because they will influence the build of dependent ports. |
| 192 | |
| 193 | Consider: [browser:trunk/dports/mail/libetpan/Portfile libetpan] @0.58_0+universal is installed. Its [changeset:66602 libetpan-config script contains -arch flags]. I now want to build etpan which depends on libetpan. [changeset:65910 etpan cannot be built universal] so I do not request the +universal variant when building etpan. Yet it still tries to build universal because it got the universal `-arch` flags from libetpan's config script, so the build fails. |
| 194 | |
| 195 | Port maintainers should therefore ensure that any `-arch` flags are removed from such scripts and files prior to installation, e.g. like this: |
| 196 | |
| 197 | {{{ |
| 198 | post-configure { |
| 199 | reinplace -E {s|-arch [a-z0-9_]+||g} \ |
| 200 | ${worksrcpath}/redland-src-config \ |
| 201 | ${worksrcpath}/redland.pc |
| 202 | } |
| 203 | }}} |
| 204 | |
| 205 | This example is taken from [browser:trunk/dports/www/redland/Portfile redland]. |
| 206 | |
| 207 | If you're using the muniversal portgroup, it's a bit more complicated because you have to reinplace in each architecture's source directory, and you have to still accommodate non-universal builds: |
| 208 | |
| 209 | {{{ |
| 210 | post-configure { |
| 211 | if {[variant_isset universal]} { |
| 212 | set dirs {} |
| 213 | foreach arch ${universal_archs_to_use} { |
| 214 | lappend dirs ${worksrcpath}-${arch} |
| 215 | } |
| 216 | } else { |
| 217 | set dirs ${worksrcpath} |
| 218 | } |
| 219 | foreach dir ${dirs} { |
| 220 | reinplace -E {s|-arch [a-z0-9_]+||g} \ |
| 221 | ${dir}/curl-config \ |
| 222 | ${dir}/libcurl.pc |
| 223 | } |
| 224 | } |
| 225 | }}} |
| 226 | |
| 227 | This example is taken from [browser:trunk/dports/www/curl/Portfile curl]. |
| 228 | |
| 229 | If you modify a port to remove `-arch` flags from its *-config scripts and/or *.pc files, don't forget to also increase the port's revision (unless you're already increasing its version). |
| 230 | |