Friday, 29 November 2013

Makefile mash

The dumbest thing so far seen in a makefile:

ECHO      = `which echo`

Apart from the apparent fact that the writer assumes that the external command which is on the path but echo might not be (hint: they don't want to use the built-in echo for whatever reason), the main error is that everywhere $(ECHO) is used it will be replaced with `which echo`

The author probably intends

 ECHO      := $(shell which echo)

which will define ECHO to be something like /bin/echo which is what they intended.

Note the := otherwise which echo would be evaluated each time $(ECHO) is used.