Is there any native makefile (GNU make, etc.) way to get prerequisites of target prerequisites? These question is not about dependency check from source files by compiler (g++ -MM, for example).
Can't find anything on subject. And as I can see, there is no special variables for this case.
To illustrate problem, here is my definition of compilation recipe from C++ source to object, pretty standard though:
##### UNIVERSAL COMPILE #####
%.o: %.cpp %.hpp
${CC} ${CFLAGS} -c $< -o $@
And then I need to build really big chains of dependencies:
a: a.o
b: b.o a.o
c: c.o b.o a.o
d: d.o c.o b.o a.o
etc, up to N times...
It is necessary because of this linking recipe:
##### UNIVERSAL LINK #####
%: %.o
${LN} ${LNFLAGS} $^ -o $@
As you can see, recipe takes all of supplied dependencies, but need to get all dependencies of all supplied dependencies.
There is no problem with overall program linking, as it is in recipe:
##### PROGRAM LINK ######
${BIN}: ${OBJ}
${LN} ${LNFLAGS} ${OBJ} -o ${BINDIR}/$@
But I need to do unit-testing, and units depends one on each others dependencies and hierarchy of testing for subsystems is very tiring to write as dependency chains that hard-coded.
Maybe I'm doing it in wrong way? Maybe there is alternatives to this link recipe? Thanks!