How do I install makefile dependencies automatically?


(Tijs Maas) #1

Hi,

I have a project that uses make to compile and it has dependencies, most of which I have not yet installed. Currently, I am compiling until there is another complaint of missing file. I know that the dependencies can also be found manually in the (complicated) makefile.

What I would like is automatic resolution and installation of all dependencies. Is that possible, preferably without changing the project?

Happy christmas,
Thanks,
Tijs


(Sean Molenaar) #2

There’s no way to find dependencies automagically. You’ll have to define them somewhere.


(Tijs Maas) #3

Okay, thanks! (+chars)


(Tres Finocchiaro) #4

I know that the dependencies can also be found manually in the (complicated) makefile.

A good make file will warn of missing dependencies and advise. Since Homebrew is one of many package managers available (projects often use vcpkg, apt, pacman), it’s generally common for a project to list these dependencies out.

Here’s an example of what this dependency chart may look like:

Libraries

Required Library Version Description
:heavy_check_mark: Qt5 >=5.0.0 Recommended over Qt4, see Using Qt5 below.
:heavy_check_mark: Qt4 >=4.3.0 Optional instead of Qt5, >=4.4.x recommended
:heavy_check_mark: libsndfile >=1.0.11 Reading and writing sound files, >=1.0.18 for branch>=master (>=1.0.26 for FLAC compression level setting for branch>=master)
:heavy_check_mark: fftw3 Fast fourier transform computing library
:heavy_check_mark: libsamplerate >=0.1.7 Audio sample rate converter
libvorbis Audio encoding library

If the project you’re working from doesn’t make this clear, you should consider contributing some form of chart for others. It would also be advisable to list the brew dependencies for others compiling on macOS. Often a simple text file or wiki page will do. Not only will this save others time, but it will also save you time when you need to repeat these steps again.

Finally – if the project warrants it – you may create a formula with all of this available. Formula are specifically intended to do what you’re requesting. Here’s one I did a few months ago. I did need some guidance from the Homebrew team to get it approved, but you can see the dependency system is built-in.