help-make
[Top][All Lists]
Advanced

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

VPATH and prerequisites


From: Rares Vernica
Subject: VPATH and prerequisites
Date: Fri, 28 Apr 2006 18:51:53 -0700
User-agent: Thunderbird 1.5.0.2 (Windows/20060308)

Hi,

I have a problem with VPATH and prerequisites.

Imagine the following structure:
  - file1.cpp
  - dir1
    - file2.cpp

"Makefile" in the root directory looks like this:
  VPATH = dir1

  file: file1.o file2.o

  file1.o: file1.cpp

"Makefile" in the "dir1" directory looks like this:
  file2.o: file2.cpp

After I run "make" in "dir1", I will have "file2.o" file in "dir1".
When I run "make" in the root dirctory, "make" creates the "file2.o" also in the root directory (it recompiles "file2").

This happends because "make" considers the "file2.o" rule from "dir1/Makefile".

How should I write this in order to stop this from happending?

I would like to keep the general structure as the project is quite large.

I tried to change "file" rule in "Makefile" of the root directory to:
  file: file1.o dir1/file2.o

but "make" returns an error:
  No rule to make target 'dir1/file2.o', needed by 'file1'

Thanks a lot,
Ray







reply via email to

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