[geeks] UNIX development and makefile discussion

microcode at zoho.com microcode at zoho.com
Fri Aug 16 01:49:32 CDT 2013


On Thu, Aug 15, 2013 at 05:12:37PM -0400, Mouse wrote:
> > Is there no way to specify an object file search path?
> 
> In general, my experience is that no, there isn't.

That's really amazing. Ok then...!

> You can sometimes get a similar effect with a bit of Makefile hackery,
> as in
> 
> OBJS = a.o b.o c.o d.o libx.o liby.o libz.o
> 
> LINKOBJS =
> .for o in $(OBJS)
> .if exists($o)
> LINKOBJS += $o
> .elif exists(../lib/$o)
> LINKOBJS += ../lib/$o
> .else
> ...hmm, is there a .error?...
> .endif
> .endfor
> 
> ...use $(LINKOBJS) in the link...
> 
> Of course, this is limited.  But it may not be entirely ludicrous in
> some cases.

Thanks. I'll look into this later. I didn't go that far but I did do semething like:

OBJLIB=../dirname

target1: ($OBJLIB)/file1.o blah blah blah

And I made sure I made the tests dependent on the main code so the object
files should always be there. If not nothing terrible is going to
happen. This code is of no great importance.


More information about the geeks mailing list