Help with a Portfile (part 2)

Ryan Schmidt ryandesign at
Wed Jan 16 18:22:44 UTC 2019

On Jan 15, 2019, at 15:55, Eric F (iEFdev) wrote:

> It's a 2 part install. C lib (dependency) + a module.
>     -

I tried to build this Portfile and found that in the libtap directory, the build system is not using the compiler nor flags that MacPorts specified. This can be fixed with the usual dance:

variant universal {}
build.env-append    CC="${}" \
                    CFLAGS="${configure.cflags} [get_canonical_archflags cc]" \
                    LDFLAGS="${configure.ldflags} [get_canonical_archflags ld]"

Then it builds fine for me. If you're ready, I'll commit this one for you.

I've made a few minor changes: Removed the name line, since github.setup sets it for you; changed the homepage to the one indicated on the GitHub project; and fixed the maintainer line: would you like to maintain the port? If so, I'll list your obfuscated email and "openmaintainer", otherwise "nomaintainer".

I've attached my revised Portfile to this ticket:

>    -

Some of the same changes apply to this Portfile, including about the name, homepage, and maintainers.

Also, every other Apache module is in the primary category "www" but you've listed this in "devel". Can we change it to "www"?

> On 1/16/19 0:35 , Ryan Schmidt wrote:
>> Sounds like apxs doesn't like the -arch flag, so don't pass that to it. Maybe using "-Wl,-arch,x86_64" instead of "-arch x86_64" is what you need. Or maybe you don't need an -arch flag at all.
> Been doing some trial'n'error here, but I think I've got it to work now. :)
> This: build.args LDFLAGS=-L${prefix}/lib
> …or: build.args LDFLAGS="-L${prefix}/lib -Wl,-arch,x86_64"
> Both works, but neither one works with: -headerpad_max_install_names
> (The original line: -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64)
> Anything to worry about? Isn't that one something about names on OS X (from quick web search)?

Yes, -headerpad_max_install_names is a linker flag that adds maximum padding to install_names of Mach-O files, so that they could be changed later with install_name_tool. MacPorts adds this flag to LDFLAGS by default.

The point is: Are the LDFLAGS being passed to apxs in the correct way? From the apxs manpage, the usage is:

       apxs -c [ -S name=value ] [ -o dsofile ] [ -I incdir ] [ -D name=value ] [ -L libdir ] [ -l libname ] [ -Wc,compiler-flags ] [ -Wl,linker-flags ] files ...

So linker flags should be passed using -Wl.

MacPorts happens to already pass the "-headerpad_max_install_names" linker flag as "-Wl,-headerpad_max_install_names" because it does not know whether LDFLAGS will be passed to the linker (which would accept this flag directly) or to the compiler (which would not). But in this case, all LDFLAGS need to be passed with this prefix.

This looks like a bug in the mod_maxminddb build system which should be reported to its developers. Its src/ correctly uses the "-Wc," prefix for CFLAGS, but does not do the equivalent for LDFLAGS. Patching that allows the build to succeed for me.

The destroot then fails because apxs is trying to install directly into prefix, bypassing destroot. I don't know how to fix that. If apxs can be told about DESTDIR that would be great, otherwise we could bypass apxs and just copy the file to the right place ourselves.

I've attached my modified Portfile to this new ticket:

More information about the macports-dev mailing list