DEV Community

Discussion on: Makefiles and alternatives?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Makefile seems namespace-limited and unpredictable to me.

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

Collapse
 
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
task-with-same-folder-same:

Collapse
 
andyvanee profile image
Andy Vanee

You can use a folder/file name as a task name and this actually highlights one of the benefits of make that a lot of other systems either don't do, or make difficult.

Suppose you have the following rules:

.PHONY: deploy
deploy: .env node_modules

node_modules: package.json
    npm install

.env:
    cp example.env .env
Enter fullscreen mode Exit fullscreen mode

Now when you run make deploy, npm install will run if the package.json file is newer than the node_modules directory and the .env file will be created if it doesn't exist.

Collapse
 
bdmorin profile image
Brian

makefile has a lot of things to complain about, unpredictable I simply don't see. It's rock solid, and hasn't changed massively in over a decade.