Keith's Blog

Makefile

Today I finally conquered my makefile problems. Over the last week, I had been trying to get my makefile to not only compile all my source into object files in a separate directory, but to also support my source files being in subdirectories. This is a challenge because makefiles are extremely cryptic and somewhat inflexible. I kept running into the problem where if my source list contained this

SRC = dir/source.cpp

The compile rule would inevitably want to make

output/dir/source.o which isn't what I wanted, I wanted it to make output/source.o

I finally got it to work today by using the VPATH macro, and using cd to change the link directory to the output directory. Now my source tree is nice and orderly with subdirectories. Yay!


0 Comments:

Post a Comment

<< Home