Live data from Hacker News

How I stopped worrying and loved Makefiles

gagor.pro

91–100 of 144 posts

Re: How I stopped worrying and loved Makefiles

#91
post #41

Earlier quoted context omitted.

Seeing people reinvent make every 10 years is very frustrating. Just learn make!

Practically any language will do for running a set of tasks to compile a program. Unless you already love this "wheel" intimately, just learn a real language and use that.

> Practically any language will do for running a set of tasks to compile a program.

Like? None of the mainstream languages have any sort of builtin for dependency resolution.

Re: How I stopped worrying and loved Makefiles

#92
post #52

Earlier quoted context omitted.

You do know that there is software that runs on more than one version of Linux (or even on a *BSD, MacOS or Windows), works with more than a single version of a compiler,...?

Thats only really a problem for C/C++, which I have had the misfortune to make build systems for. The solution is not to ship complicated and bug infested build systems, it is to fix the dependency problem in the same way any other language has done so far and until we do this, ship the dependencies with the program. And if you aren't making a GUI and don't need to target Windows, just wrap it in Docker, which enforc…

> if you aren't making a GUI and don't need to target Windows, just wrap it in Docker

In other words, if you also don't need to target MacOS or *BSD, which were the parent's stated requirements. MacOS can't run Docker, and BSDs seem to be unstable/unsupported targets, so the only stable way to get Docker on such a machine is to run Linux in a VM. Which isn't really a solution for cross-platform development, as it is a denial of it.

(Also, if you were to go down that route, why not just ship the VM; rather than dragging in all the crap that Docker entails?)

Re: How I stopped worrying and loved Makefiles

#93
post #70

Earlier quoted context omitted.

Sed confuses me more than awk but you're right. That would also remove the only use of awk in my makefile (sed is there already for hacking around spaces in filenames). Whitespace padding output in sed is probably horrible, column looks simpler than printf via bash or trying to use make's $info.

Whilst acknowledging that "Confused by SED" has overlap with "have used SED for 40 years and have three books purely on SED" I can recommend https://www.grymoire.com/Unix/Sed.html as a reference some might occasionally swear by. Anyhow, sed is a marvelous utility. Unfortunately, most people never learn its real power. The language is very simple, but the documentation is terrible. The Solaris on-line manual pages for…

After a slightly dubious use of time, I can confirm that columns is not necessary. Also noticed that the original version missed double_colon:: style targets. I fear sort is not necessary either but one has to draw the line somewhere.

  HELP_PADDING := 30
  
  .PHONY: awkhelp
  awkhelp: ## Write this help using awk
   @echo "awkhelp:"
   @awk 'BEGIN {FS = ":.*#+"}; /^[a-zA-Z_*.-]+:.*## .*$$/ {printf "  %-'$(HELP_PADDING)'s %s\n", $$1, $$2}' \
   $(MAKEFILE_LIST) | \
   sort
  
  .PHONY: sedhelp
  sedhelp: ## Write this help using sed
   @echo "sedhelp:"
   @sed -E \
   -e '/^([a-zA-Z_*.-]+::?[ ]*)##[ ]*([^#]*)$$/ !d # grep' \
   -e 's/([a-zA-Z_*.-]+:):?(.*)/  \1\2/ # drop :: and prefix pad' \
   -e ':again s/^([^#]{1,'$(HELP_PADDING)'})##[ ]*([^#]*)$$/\1 ##\2/ # insert a space' \
   -e 't again # do it again (termination is via {1, HELP_PADDING})' \
   -e 's/^([^#]*)##([^#]*)$$/\1\2/ # remove the ##' \
   $(MAKEFILE_LIST) | \
   sort

Re: How I stopped worrying and loved Makefiles

#94

If you’re really looking for a tool to collect small steps/script I highly recommend you check out the ‘just’ cli tool. It’s completely replaced our use of Make and the syntax is much easier.

I've always wanted to use one of those, but you have to convince the other developers on your team to use it as well. Make is a relatively easy sell because it's on pretty much every system or at least trivial to install and has decades of reputation.

Re: How I stopped worrying and loved Makefiles

#95
post #2

Even the slightest attempt at guessing the host system or searching for tools present on a system will quickly convert this into a blog article earnestly begging for deep societal changes and analyses the inevitable marching of time.

Hahaha. Yeap. And project dependency analysis and library feature detection quickly demand the GNU variant, autotools (gasp!), clunky scripts, or something else. Use make for simple things and simple things only.

Eric S. Raymond has a new project to eliminate the need for autotools: https://gitlab.com/esr/autodafe

It appears to give the benefits of autotools with the simplicity of make.

Re: How I stopped worrying and loved Makefiles

#97

If you’re really looking for a tool to collect small steps/script I highly recommend you check out the ‘just’ cli tool. It’s completely replaced our use of Make and the syntax is much easier.

It doesn't do conditional processing of only out of date dependencies though, which is something that is often needed.

Re: How I stopped worrying and loved Makefiles

#98

Makefiles fill that great need for a high-level 'scripting DSL', where you have a lot of different programs (or scripts), with a loose set of dependencies or order of operation, and you want a very simple way to call them, with some very simple logic determining the order, arguments to pass, parallelization, etc. Their ubiquity on all platforms makes it even easier to use them. I much prefer Make to alternatives like…

Seeing people reinvent make every 10 years is very frustrating. Just learn make!

Make is conceptually great but brings a lot of legacy baggage. You often need to set up .PHONY targets, reset .SUFFIXES, and/or set MAKEFLAGS += --no-builtin-rules. There's also dollar-symbol variables (which plague Perl and shell as well) which made lots of sense in the 1970s with teletypes but hinder readability today (what the hell was $@ again?).

Re: How I stopped worrying and loved Makefiles

#99
post #77
post #50

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/

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.
Post reply on HN