Subject: Re: Makefile rules
To: Stuart Brooks <stuartb@cat.co.za>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-userlevel
Date: 09/13/2004 16:57:32
>Thanks for all the pointers, something for me to chew on :). I've had a
>brief look at the /usr/share/mk stuff and I think I'll give that a good
>solid read before posting any more questions. It looks like it might answer
>quite a few of them.

The best way to use BSD make is with the share/mk/*.mk macros.  A typical
makefile should be no more complex than:

PROG=foo
SRCS=foo.c parser.y lexer.l

.include <bsd.prog.mk>

of course, that's far from your originally posted setup ;-)
in which (IIRC) you had src's in . and wanted to compile to dir/*.o
which is pretty much the opposite of the way bmake works.

I.e it's best (causes fewer headaches) to compile to . and have srcs found
elsewhere via .PATH:  eg.

.PATH: /my/src /my/other/src
SRCS= foo.c goo.c

will find /my/other/src/foo.c and /my/src/goo.c (assuming that's where 
they live) and the normal suffix rules will compile them to foo.o and goo.o

By default bmake will automatically chdir to ./obj (if it exists) before 
generating but some folk don't like that.  There are lots of options though
and if you don't mind magic you can do pretty slick stuff.

GNU make can of course do many of the same things - but you'd have to write
a lot more makefile.

--sjg