RE: Generating pattern rules for various directories

"Pierre-Julien VILLOUD" <[email protected]>
Newsgroups gmane.comp.gnu.make.windows
Message-ID <[email protected]>
Thank both of you for your answers :) ! Obviously your solution works... I
saw this directive in the middle of the long make doc... But I didn't make
the connection... 

Thanks again !

Pierre-Julien VILLOUD

-----Message d'origine-----
De : Dave Korn [mailto:[email protected]] 
Envoyé : jeudi 7 août 2008 17:19
À : 'Pierre-Julien VILLOUD'; [email protected]
Objet : RE: Generating pattern rules for various directories

Pierre-Julien VILLOUD wrote on 07 August 2008 15:03:

> I'm trying to write a generic makefile with gnu-make under windows
> (unxUtils). The problem is that my source files are not in the same
> directory.  
> 
> For example :
> 
> Dir1/Dir2 : directory where is located the makefile and some source files
> and where I run make. 
> 
> Dir3/ : some other sources files.

> So I tried something like that with (INCDIRS=Dir1/Dir2 Dir3 Dir3/Dir4)
> but it doesn't work L. 

> As the directories in INCDIRS change from a project to another I can't
> write explicitly the rules. Is there a way to bypass this problem and
> generate those targets ?  

  Wouldn't 

vpath %.cpp $(INCDIRS)

combined with a straightforward 

$(OBJDIR)/%.o:%.cpp
	$(CPP) -o $@ -c $< $(CFLAGS) \
		$(foreach DIRECTORY,$(INCDIRS),-I(DIRECTORY))

... do the job?



    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.