Hacker News new | past | comments | ask | show | jobs | submit login

This pattern of usage always seems like abuse.

When `make` is used as a glorified front-end to `bash` scriptlets, why not use `bash` directly instead of having two-level of scripting?

See: https://blog.aloni.org/posts/bash-functional-command-relay/




Because PHONY targets can do that, too, and without the needless manual work. Because a Makefile can still do Makefile things: PHONY targets depending on other PHONY targets, which so happens to depend on that one openapi json export you also create, which in turn depends on ...

You can do that in Bash. And now you've reinvented Makefile, but poorly.


Because the Makefile also becomes a central place of what you can run in a project without having dozens of different shell scripts. You can comment on targets, depend on others. Makefile targets to restore, the build i18n files, etc

I made a bash script that takes your Makefile and gives you a nice dialog menu for the targets that have comments. Works nicely as a self documenting project command menu.

https://gist.github.com/oppianmatt/dcc6f19542b080973e6164c71...

https://private-user-images.githubusercontent.com/48596/3262...


GNU Make gives me:

   - tab completion of targets
   - automatic dependency execution
   - automatic entry points between every task
   - result caching
   - parallel execution
Yes, it’s possible to do all of this by hand in shell scripts. But why would I, when Make is ubiquitous and battle-tested?


Tab completion of targets is usually done by a separate package, not by GNU make itself: bash-completion.


Yes, that's true. But it is "on-by-default" for 95% of desktop Linux machines, with no special action needed.


Its on until you try to tab-complete a filename that is created through make but the completion script can't detect it at which point the entire bash-completion package is uninstalled.


What?


Making sure a dependency is up to date before doing something is annoying. Building a representation of dependencies to figure out what can be done in parallel is a bit more complex. Doing it for dozens of targets is a major pain in the backside.

Sure, you can do it in bash, or python, or whatever. But then you have a cumbersome, not particularly interesting piece of code full of boiler plate. Of course, you can design it a bit, organise things neatly, and then use a config file because fiddling with the code in each project is unsustainable in the long run. At this point, you’ve just made a poor copy of make and thrown away all the good bits that result from decades of experience and weird corner cases.

The syntax of Makefiles is terrible, but make itself is very useful and versatile.

And that pattern is not abuse, it’s the sort of things Make was designed for. It’s just that we’re used to think of make as this old thing that just runs a compiler and that’s such a pain to deal with that we need Makefile generators to do it properly. And certainly that’s true for complex software compilation, but make is more versatile than that.


`make` does dependency resolution. That's its original job, by the way, and calling out the dependency resolution steps to bash was the original intention.


Also there are plugins for all editors to allow clicking on a target and it runs code. This would be significantly harder with bash.

It is abuse, but people love ergonomics more than they love reducing dependencies


If you use Make to build, and you use Make to deploy, it's good for ergonomics, and it's good for reducing dependencies.

Certainly abuse, but hey.


Turns out software is for humans, mostly :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: