DEV Community


Makefiles and alternatives?

Pacharapol Withayasakpunt
Currently interested in TypeScript, Vue, Kotlin and Python. Looking forward to learning DevOps, though.
・1 min read

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

Recently, I have found, 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 --

Discussion (8)

avalander profile image
Avalander • Edited

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.

jotafeldmann profile image
Jota Feldmann • Edited

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 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:

patarapolw profile image
Pacharapol Withayasakpunt Author

Makefile seems namespace-limited and unpredictable to me.

I cannot use folder name as a task name...

jotafeldmann profile image
Jota Feldmann

As with everything, including computers, there are trade-offs. Don't judge ONLY by the first contact or StackOverflow responses. We need to dig that kind of long term solution by its possibilities.

About using the folder name, try:

.PHONY: task-with-same-folder-same

louy2 profile image
Yufan Lou

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.

jozsefsallai profile image
József Sallai • Edited

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

yuu profile image

would you like a Rake?

patarapolw profile image
Forem Open with the Forem app