Using GNU utils on Macs for Makefile compatibility

By on September 12, 2018 - Geekery Tags:

One problem I see often with local builds are Makefiles that use modern GNU features in common commands like sed, awk, and tar. If the product only runs on Linux, writing backwards compatible versions for the older BSD-based commands on Macs may not be an effective use of time.

A simple fix is to libexec/gnubin directory to your path as documented here: Install and Use GNU Command Line Tools on macOS. However this changes your active environment, which might break scripts expecting to run on macOS. Further, this isn’t a repeatable configuration that can be safely used by others.

A better way is to explicitly configure the GNU versions to ensure they are used during the build. Read More »