help-make
[Top][All Lists]
Advanced

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

RE: VPATH


From: Paul Smith
Subject: RE: VPATH
Date: Wed, 14 Sep 2011 21:01:16 -0400

On Wed, 2011-09-14 at 01:53 -0700, MD.Mahbubur Rahman wrote:
> So for these two lines:
> files_hpp = $(wildcard *.h) 
> files_cpp = $(wildcard *.cpp)
> 
> How I can make VPATH work for?

I'll answer this:

        files_hpp = $(foreach DIR,$(subst :, ,$(VPATH)),$(wildcard $(DIR)/*.h)
        files_cpp = $(foreach DIR,$(subst :, ,$(VPATH)),$(wildcard $(DIR)/*.cpp)

but I'll say that IMO this is a bad idea.  I personally always recommend
that makefiles list the files they want to compile explicitly, and not
try to get them via wildcard.  The latter is very error-prone: extra
files might exist and be accidentally compiled; files may be missing and
not be compiled, etc.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "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]