Assign a makefile variable value to a bash command result?

You will need to double-escape the $ character within the shell command:

HEADER = $(shell for file in `find . -name *.h`;do echo $$file; done)

The problem here is that make will try to expand $f as a variable, and since it doesn't find anything, it simply replaces it with "". That leaves your shell command with nothing but echo ile, which it faithfully does.

Adding $$ tells make to place a single $ at that position, which results in the shell command looking exactly the way you want it to.


Why not simply do

HEADER = $(shell find . -name '*.h')