%% lists <[EMAIL PROTECTED]> writes:

  l> I have a number of sources that I wish to compile into executables. 
  l> They can all be processed as:


  l> file1: file1.o
  l>    $(CXX) -o $@ $(STUFF) $<


  l> I tried to automate this for files 1-9 by:


  l> EXEC_SRCS := file1.cc file2.cc file3.cc ... file9.cc
  l> EXECS := $(EXEC_SRCS:.cc=)

  l> $(EXECS): $(addsuffix .o,$@)
  l>    $(CXX) -o $@ $(STUFF) $<

You can't use $@ in the prerequisite list.  The target and prerequisites
are expanded immediately as the file is read, but the automatic
variables like $@, $<, etc. are not available until later, when the
command script is being invoked.

See the GNU make manual section on how expansion works.

  l> Why doesn't this work?  Is there a way to automate a list of files like 
  l> this?  I understand I could probably give all the executable files an 
  l> extension like .t and then use a pattern substitution to process them 
  l> all.  Any way to do this without a special extension?

Why would you need an extension?  If there's no extension, just use:

    % : %.o
            ....

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          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


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to