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

_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to