[net.unix] Question on make

chim@ncsu.UUCP (Bill Chimiak) (06/30/84)

When composing a makefile, if I wish to
have a program, pgm, be dependent on an archive rather
than use the .o files in a macro statement, 
how is this done?  Let's say the makefile initially
reads:

OBJECTS = x.o y.o z.o
pgm: $(OBJECTS)
	cc $(OBJECTS) -o pgm
x.o : defsx.h
y.o : defsy.h

but I want it to read instead something like:

pgm: file.a
	cc file.a -o pgm
where x.o, y.o and z.o are in the archive file.a .

thomas@utah-gr.UUCP (Spencer W. Thomas) (07/02/84)

> ...
> but I want it to read instead something like:
> 
> pgm: file.a
> 	cc file.a -o pgm
> where x.o, y.o and z.o are in the archive file.a .

It looks like this isn't really a make question, but a cc/ld question.
If, say, x.o is first in file.a, and contains the symbol _main, then it 
load properly.  To make sure that a particular file is included from the
library, you can use the -u flag of ld.  Pick a symbol which is defined
in x.o, and add '-u _symbol' to the beginning of your cc line:

cc -u _x_symbol -u _y_symbol -u _z_symbol file.a -o pgm

=Spencer