shake: dependency on shared library that is built internally in the project

63 Views Asked by At

In my project, I want to build a shared library libfoo.so first, then build some test programs that use this shared library. For the test programs, if I use need

need libfoo.so

then they will be rebuilt every time libfoo.so is updated. Instead, I want to build the test programs after libfoo.so exists and the header files change (or build the test programs for the first).

The dependency on the header files can be done through gcc -MMD -MF and needMakefileDependencies.

How do I express the dependency on the existence of libfoo.so without forcing rebuild every time?

Thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

If I understand properly, you build a library libfoo.so which also produces some header files in order to build itself. You want to compile some programs which make use of those header files, but depending on libfoo.so itself causes your programs to rebuild if it changes, which is excessive.

Assuming that, the answer is orderOnly ["libfoo.so"]. This construct ensures that libfoo.so is built before continuing (and thus that the header file is correct), but does not actually depend on it. The main use of orderOnly is when you want "a lot of stuff" to be built, and then you scan it (e.g. with gcc -MMD -MF) to figure out exactly which pieces to depend on.

0
On

I think that I can let shake write a temporary file with fixed content every time libfoo.so is built and let the test programs depend on this temporary file. This temporary file marks the existence of libfoo.so.