Well, maybe it wasn't all that clear -- so let me back up a little.
A static library is created by the
ar (archive) utility and contains compiled object files (.o files). It will be named
libsomething.a so that you can link a program with a
-lsomething. The math library, for example, is named
libm.a and you link it with
-lm. If you look in
/usr/lib (or
/usr/lib64 there are quite a few static libraries named libsomethng.a; that's what they are, they were created with the
ar utility, and you link them to a program with
-lsomething.
How you create a static library is laid out in the
Makefile example above. As I mentioned,
make knows how to create a static library using a compiler and the
ar utility if the
Makefile is put together as in the example. You have source files (say, .c), you want to have object files (.o) and you want those object files put into a searchable archive file (aka "library") that can be linked with
-lsomething.
The Makefile syntax that does this is
Code:
$(LIBRARY): $(LIBRARY)(function_name.o) \
$(LIBRARY)(function_other.o)
The
make utility has built-into it what that syntax means and what to do with it.
The other lines that are important are the dependency lines:
Code:
$(LIBRARY)(function_name.o): $(BASDIR)/include/header_file.h
The tokens that are used, LIBRARY, BASDIR, and others are replaced with their definitions (at the top of the
Makefile) for human convenience -- much easier to type LIBRARY that to type
libsomethig.a over and over again. The file also takes advantage of
make built-in token definitions such as CFLAGS (which we have added to for our particular use).
Tokens enclosed in braces ( {} ) are system environment variables, those enclosed in parens ( () ) are locally defined in the
Makefile.
It's worth your time and effort to get to know
make if you're going to be doing development work for any length of time -- makes your life much, much easier.
Hope this helps some.