Linux programming question (GNU make)

Was wondering, how can you put a for loop into a makefile so it works?

Something like:



sub:    $(HEADERS)
          for dir in $(SUBDIRS); do @echo $$dir done


Doesn’t seem to work for me although i’ve seen the syntax used elsewhere, all I get is an “unexpected end of file” error from bash.

Anyone got any clues? Have asked this elsewhere, but the so-called gurus don’t seem to have an answer.

Check your syntax, it should be:


sub:    $(HEADERS)
          for dir in $(SUBDIRS); do @echo $$dir; done

You were missing a semicolon. The “unexpected end-of-file error” coming from make generally means it was expecting something (like a “;”) and never found it.

Thanks, it builds now!

I’m just a bash newbie you see …