I was trying to take advantage of make's library lookup to force a
local copy of the lib source to build if it can't find one already
installed when I came across the following.

The Makefile below (assuming two source files foo.cpp and
main.exe.cpp) forces main.exe to relink on every run

main.exe: -lfoo
-lfoo: libfoo.a(foo.o) ;

Relevant debug info below

  No need to remake target '-lfoo'; using VPATH name 'libfoo.a'.
 Finished prerequisites of target file 'main.exe'.
 Prerequisite 'main.exe.cpp' is older than target 'main.exe'.
 Prerequisite 'libfoo.a' of target 'main.exe' does not exist.
Must remake target 'main.exe'

It's kind of strange that make seems to determine that the lib doesn't
need remaking but can't then find it, but the manual only mentions
when "-l" is a prerequisite so are they simply not supported when used
as targets on their own like this?

The following works

main.exe: -lfoo
-lfoo libfoo.a: libfoo.a(foo.o) ;

although make will always prefer the local copy of the lib.

_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to