[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [linuxgames] Makefiles



On Sun, Jul 20, 2003 at 06:33:54PM +0200, Francesco Orsenigo wrote:
> 
> Ok, i finally entered the wonderful world of Makefiles.
> I cut my compile times from 2 minutes to an average of 5 secs and that's fine.
> But there are thing left obscure to me.
> 
> 1)
> I build dependencies and put them in a directory, DEPS/
> How can i tell make to create DEPS/ if it not exists, _BEFORE_ that it
> starts generating dependencies
<snip>


I'm not sure it's the best way, but in the past I've done something like this
for an "obj" directory (for ".o" files to go into, so that "src/" stays
pristine, and "./" doesn't get cluttered)...

I simply make all .o files 'depend on' "obj".

And then I add an "obj" target which just does:

  mkdir obj


I don't have an exact exmaple in front of me, and am 'running on emtpy',
sleep-wise, but it'd be SOMETHING along the lines of:


  obj/foo.o:	src/foo.c src/foo.h obj
	$(CC) src/foo.c -o obj/foo.o

  obj:
	mkdir obj


Try something like that.  I hope you consider it at least a LITTLE more
elegant. ;)


Of course, the dumb solution would be to have a hidden file inside an "obj"
directory that gets included with your distribution of the source.  ;^)


That works, too!

-- 
bill@newbreedsoftware.com                           Got kids?  Get Tux Paint! 
http://newbreedsoftware.com/bill/       http://newbreedsoftware.com/tuxpaint/