Imagine I have this:

```
PROJECT1 := /path/to/first
PROJECT2 := /path/to/second
PROJECT3 := /path/to/third

```

I am doing a find to collect all `c,cpp,h` files from inside them. I have something like:

```
PROJECT1_CPP := $(shell find $(PROJECT1) -name "*.cpp" -type "f")
PROJECT1_C := ... ( the same happens for PROJECT2 and PROJECT3 )

```

Now, I could add targets for each of them like:

```
project1.lib: $(PROJECT1_OBJS)
  ...

project2.lib: $(PROJECT2_OBJS)
  ...

project3.lib: $(PROJECT3_OBJS)
  ...

```

The thing with this approach is: there's a lot of repetitive-code ( all the actions for all the builds are almost the same ). I would like to be able to do something more generic, like:

```
PROJECTS := /path/to/first
PROJECTS += /path/to/second
PROJECTS += /path/to/third

```

And then somehow iterate through them and build them. Something like this pseudocode:

```
foreach project in PROJECTS
  gather C/C++ files
  build them
  link them

link everything together

```

Could you give me any pointers as to where I should start? Is this even possible in Make?