Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a for loop in make recipe

I would like to use a loop to find some files and rename them:

  for i in `find $@  -name *_cu.*`;do mv $i "$(echo $i|sed s/_cu//)"
  done

This works in the shell. But how can I do this in a makefile recipe?

like image 773
Steve Wang Avatar asked Jan 06 '12 10:01

Steve Wang


1 Answers

I found this useful, trying to use for loops to build multiple files:

PROGRAMS = foo bar other

.PHONY all
all: $(PROGRAMS)
$(PROGRAMS):
    gcc -o $@ [email protected]

It will compile foo.c, bar.c, other.c into foor bar other executables

like image 128
fedeb Avatar answered Oct 03 '22 20:10

fedeb