More Makefile Automation
Posted: Fri Jun 22, 2007 1:37 am
Hi,
I have followed Solar's makefile tutorial on the wiki which was extremely useful (up to now, I had been adding each object file separately).
One question with the automation side though. How can I make it so that all my objects are compiled in a single directory? I'll show you the problem:
This is fine, but as you can probably see, it means that objects are compiled in to the source directory. Of course, the following:
resolves the problem, but *only* if all source files are in the same directory, "c/". How do I substitute the .c for .o, and substitute *any path* for obj/? I know that if I want my source directories less cluttered I could just use the mv command, but the make will always do a full build.
Any help from anyone more familiar with makefiles is appreciated!
Cheers,
Adam
I have followed Solar's makefile tutorial on the wiki which was extremely useful (up to now, I had been adding each object file separately).
One question with the automation side though. How can I make it so that all my objects are compiled in a single directory? I'll show you the problem:
Code: Select all
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
Code: Select all
OBJFILES := $(patsubst c/%.c,obj/%.o,$(SRCFILES))
Any help from anyone more familiar with makefiles is appreciated!
Cheers,
Adam