How to generate a Makefile with source in sub-directories using just one makefile.

Posted by James Dean on Stack Overflow See other posts from Stack Overflow or by James Dean
Published on 2008-10-23T19:56:32Z Indexed on 2010/03/20 19:11 UTC
Read the original article Hit count: 272

Filed under:
|

I have source in a bunch of subdirectories like:

src/widgets/apple.cpp
src/widgets/knob.cpp
src/tests/blend.cpp
src/ui/flash.cpp

In the root of the project I want to generate a single Makefile using a rule like:

%.o: %.cpp
   $(CC) -c $<

build/test.exe: build/widgets/apple.o build/widgets/knob.o build/tests/blend.o src/ui/flash.o
   $(LD) build/widgets/apple.o .... build/ui/flash.o -o build/test.exe

When I try this it does not find a rule for build/widgets/apple.o. Can I change something so that the %.o: %.cpp is used when it needs to make build/widgets/apple.o ?

© Stack Overflow or respective owner

Related posts about make

    Related posts about makefile