help-make
[Top][All Lists]
Advanced

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

Action as a prerequisite


From: lists
Subject: Action as a prerequisite
Date: Tue, 09 Aug 2005 19:09:19 -0400
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

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


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


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


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

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


Make won't let me use an action as a prerequisite.  As a test I tried:


$(EXECS): $(addsuffix .o,$@)
        @echo TEST $@
        @echo TEST $(addsuffix .o,$@)
        @echo TEST $<


and when I "make file1" I get


TEST file1
TEST file1.o
TEST


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

-
natch




reply via email to

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