help-make
[Top][All Lists]
Advanced

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

Re: VPATH problem


From: Michael Ludwig
Subject: Re: VPATH problem
Date: Sun, 19 Feb 2012 23:53:14 +0100
User-agent: Mutt/1.5.20 (2009-12-10)

Michael Ludwig schrieb am 19.02.2012 um 23:46 (+0100):

> Just wanted to add that you could get by with a simpler Makefile,
> relying on implicit rules (which would also avoid the problem you ran
> into because you hardcoded a recipe):
> 
> $ find
> ./Makefile
> ./src
> ./src/hello.cpp

You could even get by without any Makefile:

$ mv Makefile Makefile.bak
$ make hello VPATH=src
g++     src/hello.cpp   -o hello
$ # Or add CXXFLAGS:
$ rm hello.exe
$ make hello VPATH=src CXXFLAGS="-Wall -O2"
g++ -Wall -O2    src/hello.cpp   -o hello

All thanks to Make's built-in rules, which do the right thing.
Check out this short list of tricks, it's well worth reading:

http://www.working-software.com/node/19

Michael

> $ cat Makefile
> CXXFLAGS = -O2 -Wall
> EXEN = hello
> VPATH = src
> 
> all: $(EXEN)
> 
> $ make
> g++ -O2 -Wall    src/hello.cpp   -o hello



reply via email to

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