Newsgroups: comp.unix.programmer Date: Sun, 13 Apr 2003 03:30:12 GMT
I am having difficulties writing a make file that generate files in alternative directories. The problem is mainly on how to generate files from generated files.
Here is an example:
Seems to me that a simple
%.o: %.c
rule can't cover the above two cases. So I'm currently writing two separated rules for it. I want to know that if this (two separated rules) is the only solution?
Thanks for your input, even a 'yes' would help. :-)
Yes. (Seriously…)
(two separated rules is the only solution)
Paul D. Smith @gnu.org Find some GNU make tips at: http://www.gnu.org http://make.paulandlesley.org
> %.o: %.c > gcc -c $CFLAGS $^ -o $@ ;\ > mv -f $@ obj
That does not work so well since it makes the .o file allways out of date.
These are the kinds of rules the OP will need.
obj/%.o : %.c gcc -c $CFLAGS $^ -o $@
obj/%.o : src/%.c gcc -c $CFLAGS $^ -o $@
src/%.c : %.l lex $LEXFLAGS $^ mv -f lex.yy.c $@
Gianni Mariani