help-make
[Top][All Lists]
Advanced

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

RE: Make: Filtering prerequisites


From: Smirnov Dmitry
Subject: RE: Make: Filtering prerequisites
Date: Fri, 7 Apr 2006 20:29:26 +0400

Well, really simple.

Let's increase complexity: suppose I have few different source lists and
compiled object should be placed in different directories (we need 2
rules obviously? dir3/subdir3/%.o and dir4/subdir4/%.o)
Those source lists MAY contain files that have equal file names.
How could I use VPATH in this case? 
Of course, I'll try to figure out this by learning make docs, but
probably your advice will be much faster and simpler.

Thanks a lot,
Dmitry

-----Original Message-----
From: Paul Smith [mailto:address@hidden On Behalf Of Paul D. Smith
Sent: Friday, April 07, 2006 8:16 PM
To: Smirnov Dmitry
Cc: address@hidden
Subject: RE: Make: Filtering prerequisites

%% "Smirnov Dmitry" <address@hidden> writes:

  sd> But the idea I'm trying to implement is simple:
  sd> Suppose I'm having the list of source files. These files can be
located
  sd> anywhere.
  sd> All I need is to compile each source file and place the result
(.o) into
  sd> some specific directory.

  sd> (let's suppose sources have different file names, i.e. there no
  sd> dir1/file1 and dir2/file1)

If that's true then there's a very simple solution: use VPATH.
Write your makefile like this:

  SOURCES = ...

  VPATH = $(sort $(dir $(SOURCES)))

  dir3/subdir3/%.o : %.c
            $(CC) $(CFLAGS) -c -o $@ $<

All done!

  sd> Unfortunately, I cannot upgrade to 3.81 since it is a company
  sd> policy now to use 3.80. But probably I could try to convince
  sd> others that we need 3.81.

Well there are a number of bugs in 3.80 that are fixed in 3.81.  But
you may not need any of the newer 3.81 features for what you want to
do.

-- 
------------------------------------------------------------------------
-------
 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]