loading...

Makefiles and alternatives?

patarapolw profile image Pacharapol Withayasakpunt ・1 min read

I don't know how to use Makefile. Do I need to install cmake first?

Recently, I have found https://github.com/tj/robo, which is a YAML-based Makefile runner. It also mentions

I'm aware of the million other solutions (Sake, Thor, etc)

So, what do you recommend I use for standardization? Otherwise, I might use npm init -y with scripts section (but too bad, it isn't YAML).

I am also looking for alternatives of concurrently -- https://github.com/tj/robo/issues/40

Discussion

markdown guide
 

I don't know how to use Makefile. Do I need to install cmake first?

No, you need to install make. Although if you're not using Windows, it's most likely already installed in your system.

I mean, there are many alternatives. Few as ubiquitous as make. I'd suggest to just read through the guide and learn you some make for the greater good.

 

Hi Pacharapol,

I recommend Makefile for some reasons:

  • Exists since 1976 (old, battle-tested);
  • It's included in Linux and macOS versions;
  • It's some sort of industry standard for common tasks.

Example: you're working in a polyglot stack (Node, Python, Java, Go). Even when you're experienced in one or two languages, you don't know how to execute some tasks (NPM for Node, Pipenv for Python, Maven/Gradle for Java, so on).

One simple way to solve that is using a common approach to create common tasks using the Makefile, and wrap the language-specific command, like make dev for npm run dev (developer profile to watch and reload changes), make test for npm test, make run for npm start (for production), make deploy, etc.

In the end, you don't need to know the tasks or read all the README.md in the repositories. And better: you can check the Makefile for all available tasks and how its work for all languages :)

Makefile its not hard: cs.colby.edu/maxwell/courses/tutor...

 

The concept of make is three prong: tracking dependency, monitoring recency, and executing commands based on the previous two. Sounds simple enough.

However, since each system is different, standardization on the concept of make means almost nothing. Almost each programming language has a slightly different way to track dependency, especially when external dependency is involved, so they often make their own tool. If you mostly write JavaScript, sticking to npm is not bad. If you like YAML, nothing wrong with robo. There are also significant communities around gulp and grunt.

Another route is to adopt an integrated build system made by a big company with existing polyglot build rules. On this front we have Google's Bazel and Facebook's Buck, both coming from Google's internal build system Blaze. They are reasonably supported with rules for many languages. A community one is Nix, which you can try if you feel scholarly and adventurous.

An alternative of concurrently is npm-run-all, which is specific to npm scripts.

 

depends on what you're working with and the complexity of the stuff you want to do
when I work with node/npm, I just use npm scripts

also, cmake is a tool used for setting up and compiling C/C++ projects