Vivek Maran
Vivek Maran

Reputation: 2753

Behaviour of VPATH in makefile

As of I understand VPATH variable can hold list of search paths for the source files that needs to be compiled. Hence I am using VPATH in the same context, as in example code-snippet below.

SFILES= src1.c src2.c src3.c
VPATH= $(PATH-1)/src

The listed sources are present in my current directory where the Makefile exists as well as in $(PATH-1)/src. When I give "make", I see the sources in current directory taking precedence over VPATH.

Is there anyway to override this behavior other than removing/relocating the sources in the current directory.

Upvotes: 0

Views: 625

Answers (1)

Stephane Rouberol
Stephane Rouberol

Reputation: 4384

I'm afraid the answer is no. From GNU make documentation: if a file that is listed as a target or prerequisite does not exist in the current directory, make searches the directories listed in VPATH for a file with that name.

Upvotes: 0

Related Questions