macOS symbol/conditional for Makefiles (porting)

Ryan Schmidt ryandesign at
Mon Dec 28 23:32:19 UTC 2020

On Dec 28, 2020, at 06:12, Christoph Kukulies wrote:

> I’m trying to compile a package „blackmagic“ (a microcontroller gdb debugging and flashing program addendum to gdb).
> It has some issues like missing packages (libftdi1 - I was able to add that via macports)
> Now I want to add some condional in the Makefile like this:
> ifdef macOS
> CFLAGS += -I/opt/local/include
> endif
> Only, macOS isn’t just the variable that works. Does macOS supply any built-in variable for building that if block?

You should not need to do this.

Most build systems should accept additional flags on the command line. For example, autotools-based build systems usually accept something like:

CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib" ./configure

If blackmagic doesn't do it that way, consult their documentation to find out how they do it. In the unlikely event that their build system does not support user-supplied flags, file that as a bug in their bug tracker. You may then need to resort to modifying their Makefile or other build files manually, and if so, since the modification is just for you, you don't need to make it conditional on macOS or anything else; just make the change unconditionally.

If you were thinking of proposing a change to the developers of blackmagic where they automatically add /opt/local paths on macOS, don't. That would annoy users trying to build it with Homebrew, Fink, or manually, and it would even annoy MacPorts users trying to build with MacPorts in a prefix other than /opt/local.

More information about the macports-users mailing list