help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: expanding $(%) in prerequisites


From: William F. Dowling
Subject: Re: expanding $(%) in prerequisites
Date: Fri, 15 Dec 2000 16:16:10 -0500 (EST)

Thanks Paul.  I have now done a couple searches, and it looks like you
answer some variant of this question quite regularly.
Must get tiring :)

In your solution
 >   include extra_objs.mk
 > 
 >   extra_objs.mk: Makefile
 >           rm -f $@
 >           for bin in $(BINS); do \
 >             echo "\$$(BIN)/$$bin : \$$($${bin}_EXTRAOBJS)" >> $@; \
 >           done

the quoting seems to work fine, but I had to protect the $(BINS), else
I get a shell syntax error when $(BINS) happens to be empty.  Here is
the working code (in case anyone reading the list can use it):

$(DEPDIR)/Extradeps : Makefile
        @echo "Building $@ ..."
        @rm -f $@
        @for bin in `echo $(EXE_NAMES)`; do \
            echo "\$$(BIN)/$$bin : \$$($${bin}_EXTRAOBJS) \$$($${bin}_LIBS)" >> 
$@; \
        done
        @for a in `echo $(A_NAMES)`;     do \
            x=`basename $$a .a` ; \
            echo "\$$(BIN)/$$a : \$$($${x}_A_COMP)" >> $@;   \
        done

EXE_NAMES contains the names of the executables I am building; A_NAMES
contains the names of the library files like foo.a I am building; my
actual code has another clause, slightly more complex but the same
idea, for shared object dependencies.

I am not wild about the dependency on Makefile.  Won't this give me
spurious re-execs of make?

Anyway, it works, and seems to be faster than what I had before.
Thanks again,

Will

-- 
William F. Dowling
ISI/Thomson Scientific (www.isinet.com)
215-386-0100 x-1156




reply via email to

[Prev in Thread] Current Thread [Next in Thread]