Makefile Build Directory and dependencies list
dependencies, g++, makefile, subdirectory
Solution
Off the top of my head
g++ $(addprefix $(BUILDDIR), $^) -o $@
should do it.
The Make manual has a list of these functions in section 8.3.
Problem
In a makefile, I build all my .o files in a build directory: ``` program: class1.o class2.o class3.o g++ $(BUILDDIR)class1.o $(BUILDDIR)class2.o $(BUILDDIR)class3.o -o $@ ``` It would be cool to generate `$(BUILDDIR)class1.o $(BUILDDIR)class2.o $(BUILDDIR)class3.o` from the dependencies list... I know that `$^` would give me the list of all dependencies, separated by spaces, but I can't deal with the sub-directory. Is it possible ? And if I have `program: class1.o class2.o class3.o configure`, can I exclude `configure` from the list ? Thank you :) Edit: Michael's solutions works well, but doing that, `make` does not find the dependencies and has to build everything everytime... Isn't there a simpler way, when making implicit rules like `program: class1.o class2.o class3.o`, to tell it to put the binaries in a build directory ?