help-make
[Top][All Lists]
Advanced

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

RE: Usage: CPPFLAGS vs VPATH


From: John Calcote
Subject: RE: Usage: CPPFLAGS vs VPATH
Date: Mon, 3 Oct 2011 09:29:15 -0600

> But if I remove the following line:
> CPPFLAGS = -I include
> The make file is not working..meaning that this line is needed for finding
header
> files from include directory. Please make me correct if I am missing
something...
> Than why the  line "VPATH = src include " is not serving the purpose to
get the
> header files from the include directory?

CPPFLAGS is expanded in the makefile on the compiler command line - the -I
option is designed to tell the compiler where to look when relative paths to
include files are specified in sources, but those paths are not relative to
the source file itself. Include files are first searched for by appending
the specified include file to the source file's directory, and then by
appending the specified file to each successive path given in -I directives.

VPATH, on the other hand, is purely a make construct that's designed to tell
make where to look for a source file *that's specified within a make rule*
is located when a path is specified that is not relative to the current
directory. 

Thus, VPATH and the -I options given in CPPFLAGS are unrelated and have
nothing to do with each other. If relative paths are given in both of these
contexts that are not relative to the current directory and containing
source file (respectively), then both constructs must be used in order for
the build to succeed.

Regards,
John




reply via email to

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