On 8/30/06, Lin George <[EMAIL PROTECTED]> wrote:
Suppose I define two macros,
OBJ_DIR = debug/foo.o debug/goo.o
SRC_DIR = src/foo.c src/goo.c
how should I write a rule to compile foo.c and goo.c
into foo.o and goo.o and put them into debug
sub-directory?
Well, here's a pattern rule to compile _any_ .c file under 'src' into
a .o under 'debug'
debug/%.o: src/%.c
$(COMPILE.c) -o $@ $<
If you wanted that to _only_ apply to the files listed in OBJ_DIR, you
would change that to a static pattern rule (check the GNU make info
pages for details):
$(OBJ_DIR): debug/%.o: src/%.c
$(COMPILE.c) -o $@ $<
BTW, it's kinda odd to name a variable containing filenames with the
suffix "_DIR". In practically every makefile I've ever seen or
written, a variable named SRC_DIR would contain just the directory of
the source files. The list of source files would be named SRCS or
similar.
Philip Guenther
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make