bg> I have a collection of C functions that I compile into a .a
bg> library (e.g. lib.a) I then write a program that links the lib.a
bg> file in when it is compiled.
bg> How do I tell make that the program needs to be recompiled if
bg> lib.a changes? Everything I try ends up giving me the error "No
bg> rule to make target lib.a", which is true. The program's makefile
bg> doesn't know how to make the library, nor would I want it to. I
bg> just want it to recompile (just relink in this case) the program
bg> when the library has been changed.
If make doesn't know how to create a prerequisite, but the prerequisite
already exists, then that is good enough for make.
So, if you have written something like:
program: lib.a
and you get an error "No rule to make target lib.a", that means that the
file "lib.a" doesn't exist. If you don't provide a rule to build it,
then you _must_ make sure it exists before make needs to use it.
Without a concrete example I can't say for sure, but offhand I suspect
you aren't including the full or correct pathname to your library in the
prerequisite list; if the library is really in the ../mylib directory,
then you need to tell make that (else how could make know whether it's
newer than the target?)
program: ../mylib/lib.a
Obviously it's probably best to make liberal use of variables,
etc. rather than hardcoding all these values.
--
-------------------------------------------------------------------------------
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist