help-make
[Top][All Lists]
Advanced

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

Re: $(BINFILES) : $(notdir $@)


From: Paul D. Smith
Subject: Re: $(BINFILES) : $(notdir $@)
Date: Sat, 12 Oct 2002 12:38:06 -0400

%% "Albert D. Cahalan" <address@hidden> writes:

  adc> Suppose $(BINFILES) is a list of files such as:
  adc> /bin/foo /sbin/bar /usr/bin/baz

  adc> I need to make each one of those depend on the program,
  adc> so that the program will be compiled before I try to
  adc> install it. None of these work:

  adc> $(BINFILES) : % : $(notdir %)
  adc>         $(install) --mode a=rx --strip $(notdir $@) $@

The explanation for this lies in the chapter "How Make Reads a
Makefile".  It does miss an explicit statement about automatic
variables; I could have sworn there was something there but I can't find
it either as per my other message.

  adc> $(BINFILES) : $(notdir $@)
  adc>         $(install) --mode a=rx --strip $(notdir $@) $@

This won't work for the same reason.

  adc> $(BINFILES) : $(@F)
  adc>         $(install) --mode a=rx --strip $(notdir $@) $@

Or this.


If you get GNU make 3.80 you can use either the $(eval ...) function
or the SysV-style $$(@F); either of these will work:

  $(BINFILES) : $$(@F)
            $(install) --mode a=rx --strip $< $@

Or:

  $(BINFILES):
            $(install) --mode a=rx --strip $< $@

  $(foreach BIN,$(BINFILES),$(eval $(BIN): $(notdir $(BIN))))


If you want to be portable to older versions of GNU make your only
option for this kind of dynamic rule creation is auto-re-exec:

  $(BINFILES):
            $(install) --mode a=rx --strip $< $@

  bins.mk : Makefile
        @rm -f $@
        @for bin in $(BINFILES); do \
           echo $$bin : `dirname $$bin` >> $@; \
         done

  include bins.mk

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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