Hello,
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 ?