makefile - How to express dependence on a shared library when making multithreaded -
i use shared library.so
in order avoid remake executables (which linked against it) when implementation (library.cpp
), not interface (library.hpp
), has changed, i.e.
obj/library.o: library.cpp library.hpp lib/library.so: obj/library.o program : program.cpp library.hpp $(cxx) program.cpp -llib -lrary
thus, program
not depend on library.cpp
or library.so
. however, when making scratch (rather remaking because of changes files), library.so
must made before program
. can ensured setting:
default: library.so program
but when using make -j
broken.
so correct way 1) ensure library.so
made before program
2) avoid re-making program
if library.cpp
has changed?
the solution want order-only prerequisite.
from types of prerequisites section of gnu make manual:
occasionally, however, have situation want impose specific ordering on rules invoked without forcing target updated if 1 of rules executed. in case, want define order-only prerequisites. order-only prerequisites can specified placing pipe symbol (|) in prerequisites list: prerequisites left of pipe symbol normal; prerequisites right order-only:
targets : normal-prerequisites | order-only-prerequisites
Comments
Post a Comment